copy --auto

Only does copy when numcopies is not yet satisfied.
This commit is contained in:
Joey Hess 2011-09-15 15:27:45 -04:00
parent 7b90cb72fc
commit a0d3a343b5
3 changed files with 16 additions and 4 deletions

View file

@ -9,11 +9,20 @@ module Command.Copy where
import Command import Command
import qualified Command.Move import qualified Command.Move
import Utility
command :: [Command] command :: [Command]
command = [repoCommand "copy" paramPaths seek command = [repoCommand "copy" paramPaths seek
"copy content of files to/from another repository"] "copy content of files to/from another repository"]
-- A copy is just a move that does not delete the source file.
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withFilesInGit $ Command.Move.start False] seek = [withNumCopies start]
-- A copy is just a move that does not delete the source file.
-- However, --auto mode avoids unnecessary copies.
start :: CommandStartAttrFile
start (file, attr) = isAnnexed file $ \(key, _) ->
autoCopies key (<) numcopies $
Command.Move.start False file
where
numcopies = readMaybe attr

4
debian/changelog vendored
View file

@ -5,8 +5,8 @@ git-annex (3.20110907) UNRELEASED; urgency=low
* Fix build without S3. * Fix build without S3.
* addurl: Always use whole url as destination filename, rather than * addurl: Always use whole url as destination filename, rather than
only its file component. only its file component.
* get, drop: Added --auto option, which decides whether to get/drop * get, drop, copy: Added --auto option, which decides whether
content as needed to work toward the configured numcopies. to get/drop content as needed to work toward the configured numcopies.
-- Joey Hess <joeyh@debian.org> Tue, 06 Sep 2011 16:59:15 -0400 -- Joey Hess <joeyh@debian.org> Tue, 06 Sep 2011 16:59:15 -0400

View file

@ -36,3 +36,6 @@ work toward having two copies of your files.
whereis other_file (2 copies) whereis other_file (2 copies)
0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop 0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop
7570b02e-15e9-11e0-adf0-9f3f94cb2eaa -- backup drive 7570b02e-15e9-11e0-adf0-9f3f94cb2eaa -- backup drive
The --auto option can also be used with the copy command,
again this lets git-annex decide whether to actually copy content.