Skip to content

(un)set with --overwrite can do better than shutil.copyfile #96

@edswangren

Description

@edswangren

It seems to me, anyway.

from commands.py:538 tiff_set

if os.path.realpath(source) == os.path.realpath(output) and source != '-':
    with tempfile.TemporaryDirectory('tifftools') as tmpdir:
        output = os.path.join(tmpdir, 'output.tiff')
        _tiff_set(source, output, setlist, unset, setfrom, **kwargs)
        with open(source, 'r+b') as fdest, open(output, 'rb') as fsrc:
           fdest.truncate(0)
            shutil.copyfileobj(fsrc, fdest)

I lost a file just now sending an interrupt during shutil.copyfileobj. os.replace or even shutil.move are safer and more efficient alternatives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions