diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-04-14 14:30:15 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-04-14 14:47:08 -0400 |
commit | 8f2cde77f63fe873341554192b1c7df71cc8bdc1 (patch) | |
tree | c3858d3491fce3732db2e6abacb91df1dd552b0e /Command | |
parent | 1835f915174e9fdf5aa73372efa80e4330b528f2 (diff) |
Preserve execute bits of unlocked files in v6 mode.
When annex.thin is set, adding an object will add the execute bits to the
work tree file, and this does mean that the annex object file ends up
executable.
This doesn't add any complexity that wasn't already present, because git
annex add of an executable file has always ingested it so that the annex
object ends up executable.
But, since an annex object file can be executable or not, when populating
an unlocked file from one, the executable bit is always added or removed
to match the mode of the pointer file.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Fix.hs | 6 | ||||
-rw-r--r-- | Command/Fsck.hs | 7 | ||||
-rw-r--r-- | Command/Lock.hs | 4 | ||||
-rw-r--r-- | Command/ReKey.hs | 9 | ||||
-rw-r--r-- | Command/Unlock.hs | 12 |
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 |