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.
This commit is contained in:
parent
d05a75e45a
commit
b7c8bf5274
12 changed files with 128 additions and 67 deletions
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 $
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue