Skip to content

ltfs_ordered_copy: copy into a destination directory again (#661) - #662

Open
MitchelTighe wants to merge 1 commit into
LinearTapeFileSystem:mainfrom
MitchelTighe:fix/ordered-copy-dir-destination
Open

MitchelTighe wants to merge 1 commit into
LinearTapeFileSystem:mainfrom
MitchelTighe:fix/ordered-copy-dir-destination

Conversation

@MitchelTighe

Copy link
Copy Markdown

Fixes #661

Since #649, CopyItem copies with open(self.dst, 'wb') so it can drive the progress bar. shutil.copy(), which it replaced, accepted a directory as the destination and kept the source file name. open() fails with "Is a directory" instead, so copying several files (or a -t list) into a directory copied nothing.

This PR appends the source file name when the destination is an existing directory, restoring the pre-v2.4.9.0 behaviour. It's a 4-line change in CopyItem.__init__.

Testing (off-tape, with a stub xattr module):

Command Before After
ltfs_ordered_copy src/a.txt src/b.txt dst Copied 0 files, Failed 2 Copied 2 files, dst/a.txt and dst/b.txt with the right contents
printf 'src/a.txt\nsrc/b.txt\n' | ltfs_ordered_copy -t dst Copied 0 files, Failed 2 Copied 2 files
ltfs_ordered_copy src/a.txt newname (single file to a new name) works still works
--keep-tree and recursive directory copies not affected not affected

A 21-case regression harness shows no other change in results.

Written with help from an AI assistant (Claude).

…eFileSystem#661)

Since LinearTapeFileSystem#649, CopyItem copies with open(self.dst, 'wb') so it can drive
the progress bar.  shutil.copy(), which it replaced, accepted a directory
as the destination and kept the source file name; open() fails with
"Is a directory", so copying several files (or a -t list) into a
directory copied nothing.

When the destination is an existing directory, append the source file
name, which restores the previous behaviour.

Fixes LinearTapeFileSystem#661
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ltfs_ordered_copy: copying several files into a directory fails with 'Is a directory' since v2.4.9.0

1 participant