From 74e01a2d0167d1fdd19cf5895eedae0b59683c3e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 5 Jun 2016 13:51:22 -0400 Subject: [PATCH] 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. --- CHANGELOG | 2 ++ Command/Move.hs | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 13091f9359..2efc4eb242 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,8 @@ git-annex (6.20160528) UNRELEASED; urgency=medium * remotedaemon: Fixed support for notifications of changes to gcrypt remotes, which was never tested and didn't quite work before. * 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 Fri, 27 May 2016 13:12:48 -0400 diff --git a/Command/Move.hs b/Command/Move.hs index 710d09d069..2d2a6a227a 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -113,23 +113,29 @@ toPerform dest move key afile fastcheck isthere = upload (Remote.uuid dest) key afile noRetry noObserver $ Remote.storeKey dest key afile if ok - then do + then finish $ Remote.logStatus dest key InfoPresent - finish else do when fastcheck $ warning "This could have failed because --fast is enabled." stop - Right True -> do + Right True -> finish $ unlessM (expectedPresent dest key) $ Remote.logStatus dest key InfoPresent - finish where - finish + finish :: Annex () -> CommandPerform + finish setpresentremote | 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 - next $ Command.Drop.cleanupLocal key - | otherwise = next $ return True + next $ do + setpresentremote + Command.Drop.cleanupLocal key + | otherwise = next $ do + setpresentremote + return True {- Moves (or copies) the content of an annexed file from a remote - to the current repository.