tahoe cp copies a source directory's children rather than the directory itself #712
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#712
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I had two entries in my local filesystem, a file named "22brain.html" and a directory named "22brain_files", which was full of other files and subdirectories. I ran {{tahoe cp 22brain* tahoe:22brain/}}}. Afterward I expected to find
tahoe:22brain/22brain.html
andtahoe:22brain/22brain_files/
, but instead I found the contents of the local "22brain_files" directory copied directly into thetahoe:22brain
directory. This breaks all the links in the "22brain.html" file and means I need to delete this directory and try again.I see that the same thing happens if I run
tahoe cp -r 22brain_files tahoe:22brain/
.See also #705 ("tahoe mv" unlinks the target even when it is a directory).
zooko forgot he had filed this ticket :-) and wrote in the duplicate ticket #1854 :
It isn't clear from the bug description or from comment:71239 whether it is just that a directory specified in the command line won't be created as a directory in the destination, or whether all subdirectories will be flattened.
Replying to davidsarah:
From my testing it appears that only the top level directories are flattened:
Here is my example folder on the local drive:
When in the directory tahoe-cp-test/, the command
tahoe cp -r * tahoe:tahoe-cp-test/
will output the following structure on the grid:This error appears to only occur when you are in the directory you want to upload.
cp -r ~/tahoe-cp-test tahoe:tahoe-cp-test
uploads the files with the correct structure.This error doesn't occur when
./
is supplied instead of*
.I believe this ticket ultimately arises from tahoe's interface design and not necessarily from a bug in the code. Because
tahoe cp
can take multiple arguments,*
is supplying both files and directories. The CLI breaks down the list of arguments into individual copy actions, so each folder and file can be viewed to have its owntahoe cp
call.In the instance of
tahoe cp -r example_dir/ tahoe:example_dir/
, the contents of example_dir/ should be placed into tahoe:example_dir/ without preserving the top level directory (by this I mean we want tahoe:example_dir/contents, not tahoe:example_dir/example_dir/contents).However with this ticket, we want the opposite behavior. By supplying
*
, we are telling tahoe to copy multiple directories to the grid, but in this instance we want to retain the top level directory (we want tahoe to create tahoe:example_dir/example_dir/ if example_dir/ is in *).In order to have the desired behavior outlined in this ticket, we need to distinguish between these two scenarios. I believe the current behavior makes sense, although it is counter intuitive to what users probably expect. I'm not sure how we can distinguish between these two behaviors while keeping support for multiple arguments since it seems like
*
is populated by the console (I could be wrong about this).Wildcards are indeed expanded by the Unix shell. I don't think that's the problem, though; the problem is that
tahoe cp
is doing the wrong thing with individual source arguments that are directories. Compare withUnix cp
:I.e.
cp -R foo bar
should create a copy offoo
itself, not the children offoo
, underbar
. (It doesn't matter whether or notfoo
is specified with a trailing slash.)tahoe cp flattens directoriesto tahoe cp copies a source directory's children rather than the directory itselfThanks for clearing that up Daira! I'll start working on this.
Here is the pull request: https://github.com/tahoe-lafs/tahoe-lafs/pull/56
Needs more work, removing 'review-needed'.
Reviewed, +1. I added #2047 for a possible cleanup that can be done separately.
Still needs docs and a NEWS entry noting the non-backward-compatible change.
We have inconsistent policies about NEWS at this point. I prefer the Twisted process, where each ticket that makes a change comes with a NEWS entry. Brian prefers — last time we talked about it, IIRC — for the Released Manager to read back through the closed tickets and write a NEWS entry for each one.
But the missing docs should definitely be fixed for this ticket. Removing the
reviewed
keyword.I couldn't find any existing documentation about the expected behavior for
tahoe cp -r
so I added an example to the docs.warner will rebase this.
In /tahoe-lafs/trac-2024-07-25/commit/b88d8b0b3ea345dec3833fdef0a98326c30572f8:
This fix may have caused a regression: #2329