diff options
-rw-r--r-- | Annex/Content.hs | 8 | ||||
-rw-r--r-- | Command/Move.hs | 14 |
2 files changed, 10 insertions, 12 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 25c291ed1..b3c62ee0a 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -175,12 +175,10 @@ lockContent key a = do lock _ (Just lockfile) = createLockFile Nothing lockfile >>= dolock . Just {- Since content files are stored with the write bit disabled, have - to fiddle with permissions to open for an exclusive lock. -} - opencontentforlock f = catchMaybeIO $ ifM (doesFileExist f) - ( withModifiedFileMode f + opencontentforlock f = catchDefaultIO Nothing $ + withModifiedFileMode f (`unionFileModes` ownerWriteMode) - (createLockFile Nothing f) - , createLockFile Nothing f - ) + (openExistingLockFile f) dolock Nothing = return Nothing dolock (Just fd) = do v <- tryIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0) diff --git a/Command/Move.hs b/Command/Move.hs index 3d9646dea..f70608a6f 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -150,11 +150,10 @@ fromOk src key = go =<< Annex.getState Annex.force return $ u /= Remote.uuid src && elem src remotes fromPerform :: Remote -> Bool -> Key -> AssociatedFile -> CommandPerform -fromPerform src move key afile = moveLock move key $ - ifM (inAnnex key) - ( dispatch move True - , dispatch move =<< go - ) +fromPerform src move key afile = ifM (inAnnex key) + ( dispatch move True + , dispatch move =<< go + ) where go = notifyTransfer Download afile $ download (Remote.uuid src) key afile noRetry $ \p -> do @@ -166,8 +165,9 @@ fromPerform src move key afile = moveLock move key $ ok <- Remote.removeKey src key next $ Command.Drop.cleanupRemote key src ok -{- Locks a key in order for it to be moved. - - No lock is needed when a key is being copied. -} +{- Locks a key in order for it to be moved away from the current repository. + - No lock is needed when a key is being copied, or moved to the current + - repository. -} moveLock :: Bool -> Key -> Annex a -> Annex a moveLock True key a = lockContent key a moveLock False _ a = a |