[tahoe-lafs-trac-stream] [Tahoe-LAFS] #2329: cp -r stops with an exception
Tahoe-LAFS
trac at tahoe-lafs.org
Mon Feb 23 19:03:02 UTC 2015
#2329: cp -r stops with an exception
-------------------------+-------------------------------------------------
Reporter: zooko | Owner: warner
Type: defect | Status: assigned
Priority: major | Milestone: 1.10.1
Component: code- | Version: 1.10.0
frontend-cli | Keywords: regression tahoe-cp review-needed
Resolution: | release-blocker
Launchpad Bug: |
-------------------------+-------------------------------------------------
Comment (by warner):
I've got a branch which adds a test that exercises the full table. While
studying how to change the code to let that test pass, I came across
another wrinkle: `cp` accepts multiple source arguments.
In general, if you have multiple source arguments, then the target must be
a directory. If the target is a directory, then you can't use unnamed
files as sources (one or multiple). The only case that accepts an unnamed
file as a source is when you're copying exactly one of them to a target
that is (or will be) a file.
Here's a list of what I think should happen (I tried to compress some of
the cases.. let me know if it doesn't seem to cover everything):
* sources are NAMEDDIR, UNNAMEDDIR, NAMEDFILE, UNNAMEDFILE
* targets are DIR, FILE, or MISSING
* single-source cases:
* cp FILE TO-FILE: replace the contents
* cp FILE TO-MISSING: create the target file
* cp NAMEDFILE TO-DIR: create/replace TO-DIR/filename
* cp UNNAMEDFILE TO-DIR: error: need a name
* (cp -r FILE X: behave same as without -r)
* cp DIR X: error: must use -r if any source is a directory
* cp -r NAMEDDIR TO-DIR: create TO-DIR/NAME/ and fill with contents
* cp -r NAMEDDIR TO-MISSING: same: TO-MISSING/NAME/ filled with contents
* cp -r UNNAMEDDIR TO-DIR: copy source/* into TO/*
* cp -r UNNAMEDDIR TO-MISSING: same: mkdir TO-MISSING, fill with contents
* multiple-source cases:
* cp X.. TO-FILE: error: many-to-one requires target is a directory
* cp NAMEDFILES.. TO-DIR: create/replace TO-DIR/filenames
* cp NAMEDFILES.. TO-MISSING: mkdir, then treat like TO-DIR
* cp UNNAMEDFILES.. X: error: need a name (1 source is ok, but not >1)
* cp FILESDIRS.. X: error: must use -r if any source is a directory
* cp -r X.. TO-MISSING: mkdir target, then treat as TO-DIR
* cp -r X.. TO-DIR:
* if X is UNNAMEDFILE: error, need a name
* if X is NAMEDFILE: create/replace TO-DIR/name
* if X is UNNAMEDDIR: copy source/* into TO/*, like with single-source
* if X is NAMEDDIR: copy source/* into TO/name/*
Next step is to figure out how to turn this into a flowchart for
`tahoe_cp.Copier.try_copy`.. I've started on the internal refactorings to
make this easier (I was wrong before when I thought the basename should be
tracked from outside of `TahoeFileSource`/etc.. treating it as a possibly-
empty property of the source instance is totally the right way to do it).
--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2329#comment:40>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage
More information about the tahoe-lafs-trac-stream
mailing list