move --to: Better behavior when system is completely out of disk space; drop content from disk before writing location log.

I noticed move --to failing when there was no disk space. The file was sent
to the remote, but it crashed before it could be dropped locally. This
could fix that.
This commit is contained in:
Joey Hess 2016-06-05 13:51:22 -04:00
parent 33a76fa530
commit 74e01a2d01
Failed to extract signature
2 changed files with 15 additions and 7 deletions

View file

@ -18,6 +18,8 @@ git-annex (6.20160528) UNRELEASED; urgency=medium
* remotedaemon: Fixed support for notifications of changes to gcrypt * remotedaemon: Fixed support for notifications of changes to gcrypt
remotes, which was never tested and didn't quite work before. remotes, which was never tested and didn't quite work before.
* list: Do not include dead repositories. * list: Do not include dead repositories.
* move --to: Better behavior when system is completely out of disk space;
drop content from disk before writing location log.
-- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400 -- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400

View file

@ -113,23 +113,29 @@ toPerform dest move key afile fastcheck isthere =
upload (Remote.uuid dest) key afile noRetry noObserver $ upload (Remote.uuid dest) key afile noRetry noObserver $
Remote.storeKey dest key afile Remote.storeKey dest key afile
if ok if ok
then do then finish $
Remote.logStatus dest key InfoPresent Remote.logStatus dest key InfoPresent
finish
else do else do
when fastcheck $ when fastcheck $
warning "This could have failed because --fast is enabled." warning "This could have failed because --fast is enabled."
stop stop
Right True -> do Right True -> finish $
unlessM (expectedPresent dest key) $ unlessM (expectedPresent dest key) $
Remote.logStatus dest key InfoPresent Remote.logStatus dest key InfoPresent
finish
where where
finish finish :: Annex () -> CommandPerform
finish setpresentremote
| move = lockContentForRemoval key $ \contentlock -> do | move = lockContentForRemoval key $ \contentlock -> do
-- Drop content before updating location logs,
-- in case disk space is very low this frees up
-- space before writing data to disk.
removeAnnex contentlock removeAnnex contentlock
next $ Command.Drop.cleanupLocal key next $ do
| otherwise = next $ return True setpresentremote
Command.Drop.cleanupLocal key
| otherwise = next $ do
setpresentremote
return True
{- Moves (or copies) the content of an annexed file from a remote {- Moves (or copies) the content of an annexed file from a remote
- to the current repository. - to the current repository.