"tahoe mv" deleted my files? #943
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
5 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#943
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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 a bunch of files in a directory and I wanted to mv them into a subdirectory. So first I ran "tahoe ls" to make sure I could get the names of the files:
Then I wrote this bash script that runs "tahoe mv tahoe:$FILENAME tahoe:new_subdir/":
All mv's reported OK. So far so good.
Then I went to play the music files from their new locations and... What the heck?? All the .mp3 files are gone, but the other files are still there??
I suspect that you moved the directory
Diablo_Swing_Orchestra-The_Butcher's_Ballroom
into itself. That is what the bash script literally says to do -- the script would have first moved all of the .mp3 files (which happen to be listed beforeDiablo_Swing_Orchestra-The_Butcher's_Ballroom
) into that directory, and then do:which causes said directory to disappear up its own... erm, I mean, become a child of itself.
I don't understand why the subsequent
mv
s printedOK
. They didn't work, as I wouldn't expect sinceDiablo_Swing_Orchestra-The_Butcher's_Ballroom
wouldn't be a child ofURI:DIR2:zssplcanct54waahwjjngjyhke:vvdpvxybwc6x7az5i64heqdnql2mdi6fspvxtje4iwzkcvvwukpq
at that point. It seems like a bug that they printedOK
, independent of whether the preceding "move a directory into itself" command should have been allowed.If you still have a direct cap to the
Diablo_Swing_Orchestra-The_Butcher's_Ballroom
directory, then it should still exist, with the .mp3 files in it.A directory being a child of itself isn't a problem per se, in a Tahoe filesystem. OTOH, Unix
mv
will not allow moving a directory into itself. On cygwin:However [tahoe mv]source:src/allmydata/scripts/tahoe_mv.py works by doing a PUT operation to create the destination link, and then if that succeeded, doing a DELETE on the source link. It would be possible to check that the source object is not the same as the parent of the destination link, but that only catches some cases that are prevented by Univ
mv
: you would still be able to move a directory into an indirect descendant, and it isn't clear how to prevent that.Replying to davidsarah:
I meant, they didn't work, as I would expect.
Normally,
tahoe mv
would not result in any data loss because the issuer of the command must have the cap that starts the destination path. In the case described in this bug, however, we delete one of the links in that path, because it is the same as the source link.Therefore, the potential data loss can be fixed by checking whether any of the destination links are the same as the link that is to be moved. This should match the expectations of users accustomed to Unix
mv
or moving files in a Windows filesystem, which would fail in the same situation. Note that we are not enforcing that it is impossible to create loops usingtahoe mv
-- that's not necessary to fix this bug.The link to be moved must be from a mutable directory, therefore it has an SI. So, the definition of "same as" for links can be "same parent directory SI, and same child name" (comparing child names as Unicode strings with
outnormalization).The later
mv
s reporting OK is a separate issue that we haven't investigated yet.[I think when this comment was written, names were not normalized. Now they are, so the comparison should be with NFC normalization.]edit:
We're not going to finish this in time for v1.6.1, but hopefully for v1.7.0!
This also affects the rename operation in SFTP. The approach of comment:75286 can also be used there, although it's a different code path.
Replying to davidsarah:
... and FTP, in theory, although the FTP
RNFR
/RNTO
commands are somewhat obscure.Don't know why that last update changed the Version field.
(http://tahoe-lafs.org/trac/tahoe-lafs/changeset/4435#file15) fixed one case in which it was possible for
tahoe mv
to print "OK" after an error (when the source file cannot be removed after the destination file has been successfully added). However, that doesn't appear to be the case involved here, because it would have had to print an error message to stderr first.Note that
tahoe mv
uses a PUT then a DELETE of the original file, not a POST with?t=rename
. It would have to be changed to do the latter (now called?t=relink
), as well as changing?t=relink
to do the path check, in order for the approach of comment:75286 to work.I just (accidentally) reproduced this problem in Tahoe-LAFS v1.7.0:
Since "papers" was one of the children of the directory, this resulted in:
Which first linked papers to be a child of papers and then unlinked it from being a child of $RWDIRCAP. Whoops!
(I saw that this was about to happen as the for loop was progressing so I switched to my web browser that was viewing $RWDIRCAP and clicked on the "papers" child that was still listed there, thus retaining a link to papers.)
Replying to davidsarah:
In fact that changeset didn't properly fix that case; see #1255. It is not true that it would have had to print an error message to stderr first, so the possibility of this being the explanation for the "OK" output in this ticket should be reconsidered.
Reminder that #1579 will probably introduce another case where this can happen.
See also ticket:1732#comment:2, which would add a web-API call that might be useful for implementing comment:75286.
Milestone renamed
moving most tickets from 1.12 to 1.13 so we can release 1.12 with magic-folders
Moving open issues out of closed milestones.
Ticket retargeted after milestone closed