summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-16 15:35:42 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-16 15:35:42 -0400
commit1d710fb8112f3c99ea8ec7324d21584024b67b36 (patch)
tree6c630abab6786439dc726f9ecbc0daa602a301fa /Command
parent77a04db58e355f7a610f6a687fbc5b9e02186523 (diff)
v6: fix locking modified file when the content is not present
Diffstat (limited to 'Command')
-rw-r--r--Command/Lock.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Command/Lock.hs b/Command/Lock.hs
index 16ddce942..741c18c15 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -65,15 +65,16 @@ performNew file key filemodified = do
next $ cleanupNew file key
where
lockdown obj = do
- ifM (sameInodeCache obj =<< Database.Keys.getInodeCaches key)
+ ifM (catchBoolIO $ sameInodeCache obj =<< Database.Keys.getInodeCaches key)
( breakhardlink obj
, repopulate obj
)
- freezeContent obj
+ whenM (liftIO $ doesFileExist obj) $
+ freezeContent obj
-- It's ok if the file is hard linked to obj, but if some other
-- associated file is, we need to break that link to lock down obj.
- breakhardlink obj = whenM ((> 1) . linkCount <$> liftIO (getFileStatus obj)) $ do
+ breakhardlink obj = whenM (catchBoolIO $ (> 1) . linkCount <$> liftIO (getFileStatus obj)) $ do
mfc <- withTSDelta (liftIO . genInodeCache file)
unlessM (sameInodeCache obj (maybeToList mfc)) $ do
modifyContent obj $ replaceFile obj $ \tmp -> do