summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Command')
-rw-r--r--Command/Fix.hs6
-rw-r--r--Command/Fsck.hs7
-rw-r--r--Command/Lock.hs4
-rw-r--r--Command/ReKey.hs9
-rw-r--r--Command/Unlock.hs12
5 files changed, 22 insertions, 16 deletions
diff --git a/Command/Fix.hs b/Command/Fix.hs
index d87bea358..3a153c761 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -67,7 +67,8 @@ start fixwhat file key = do
breakHardLink :: FilePath -> Key -> FilePath -> CommandPerform
breakHardLink file key obj = do
replaceFile file $ \tmp -> do
- unlessM (checkedCopyFile key obj tmp) $
+ mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
+ unlessM (checkedCopyFile key obj tmp mode) $
error "unable to break hard link"
thawContent tmp
modifyContent obj $ freezeContent obj
@@ -77,7 +78,8 @@ breakHardLink file key obj = do
makeHardLink :: FilePath -> Key -> CommandPerform
makeHardLink file key = do
replaceFile file $ \tmp -> do
- r <- linkFromAnnex key tmp
+ mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
+ r <- linkFromAnnex key tmp mode
case r of
LinkAnnexFailed -> error "unable to make hard link"
_ -> noop
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 2e7579b5b..81618600f 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -301,12 +301,13 @@ verifyWorkTree key file = do
case mk of
Just k | k == key -> whenM (inAnnex key) $ do
showNote "fixing worktree content"
- replaceFile file $ \tmp ->
+ replaceFile file $ \tmp -> do
+ mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
ifM (annexThin <$> Annex.getGitConfig)
- ( void $ linkFromAnnex key tmp
+ ( void $ linkFromAnnex key tmp mode
, do
obj <- calcRepo $ gitAnnexLocation key
- void $ checkedCopyFile key obj tmp
+ void $ checkedCopyFile key obj tmp mode
thawContent tmp
)
Database.Keys.storeInodeCaches key [file]
diff --git a/Command/Lock.hs b/Command/Lock.hs
index f002f016a..1cd50de7b 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -78,7 +78,7 @@ performNew file key filemodified = do
mfc <- withTSDelta (liftIO . genInodeCache file)
unlessM (sameInodeCache obj (maybeToList mfc)) $ do
modifyContent obj $ replaceFile obj $ \tmp -> do
- unlessM (checkedCopyFile key obj tmp) $
+ unlessM (checkedCopyFile key obj tmp Nothing) $
error "unable to lock file"
Database.Keys.storeInodeCaches key [obj]
@@ -92,7 +92,7 @@ performNew file key filemodified = do
liftIO $ nukeFile obj
case mfile of
Just unmodified ->
- unlessM (checkedCopyFile key unmodified obj)
+ unlessM (checkedCopyFile key unmodified obj Nothing)
lostcontent
Nothing -> lostcontent
| otherwise = modifyContent obj $
diff --git a/Command/ReKey.hs b/Command/ReKey.hs
index 79c588ccc..4d2039530 100644
--- a/Command/ReKey.hs
+++ b/Command/ReKey.hs
@@ -61,7 +61,7 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
- and vulnerable to corruption. -}
( getViaTmp' DefaultVerify newkey $ \tmp -> unVerified $ do
oldobj <- calcRepo (gitAnnexLocation oldkey)
- linkOrCopy' (return True) newkey oldobj tmp
+ linkOrCopy' (return True) newkey oldobj tmp Nothing
, do
ic <- withTSDelta (liftIO . genInodeCache file)
{- The file being rekeyed is itself an unlocked file, so if
@@ -69,7 +69,7 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
oldobj <- calcRepo (gitAnnexLocation oldkey)
v <- tryNonAsync $ modifyContent oldobj $ do
replaceFile oldobj $ \tmp ->
- unlessM (checkedCopyFile oldkey file tmp) $
+ unlessM (checkedCopyFile oldkey file tmp Nothing) $
error "can't lock old key"
freezeContent oldobj
oldic <- withTSDelta (liftIO . genInodeCache oldobj)
@@ -95,9 +95,10 @@ cleanup file oldkey newkey = do
liftIO $ removeFile file
addLink file newkey Nothing
, do
+ mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
liftIO $ whenM (isJust <$> isPointerFile file) $
- writeFile file (formatPointer newkey)
- stagePointerFile file =<< hashPointerFile newkey
+ writePointerFile file newkey mode
+ stagePointerFile file mode =<< hashPointerFile newkey
Database.Keys.removeAssociatedFile oldkey
=<< inRepo (toTopFilePath file)
)
diff --git a/Command/Unlock.hs b/Command/Unlock.hs
index ac99d5cd3..2fe1175a8 100644
--- a/Command/Unlock.hs
+++ b/Command/Unlock.hs
@@ -15,6 +15,7 @@ import Annex.Version
import Annex.Link
import Annex.ReplaceFile
import Utility.CopyFile
+import Utility.FileMode
cmd :: Command
cmd = mkcmd "unlock" "unlock files for modification"
@@ -50,16 +51,17 @@ start file key = ifM (isJust <$> isAnnexLink file)
performNew :: FilePath -> Key -> CommandPerform
performNew dest key = do
+ destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus dest
replaceFile dest $ \tmp -> do
- r <- linkFromAnnex key tmp
+ r <- linkFromAnnex key tmp destmode
case r of
LinkAnnexOk -> return ()
_ -> error "unlock failed"
- next $ cleanupNew dest key
+ next $ cleanupNew dest key destmode
-cleanupNew :: FilePath -> Key -> CommandCleanup
-cleanupNew dest key = do
- stagePointerFile dest =<< hashPointerFile key
+cleanupNew :: FilePath -> Key -> Maybe FileMode -> CommandCleanup
+cleanupNew dest key destmode = do
+ stagePointerFile dest destmode =<< hashPointerFile key
return True
startOld :: FilePath -> Key -> CommandStart