diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-05-19 14:53:19 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-05-19 14:53:19 -0400 |
commit | 11c97d173423bd5d3320124670ccc3b4c8675c06 (patch) | |
tree | 05d822435109e1f8d49410bcc4e91b1457409288 /Utility/FileMode.hs | |
parent | 349075722085c704398e7a746dc83d1124a8e74f (diff) |
honor core.sharedRepository settings in lockContent
The content file may not be owned by the user running git-annex, in which
case, setting the owner write bit was not enough to let lockContent
act on the file. However, with some core.sharedRepository configs, the file
should be writable by the user's group. So, the thing to do is to call
thawContent on it.
Diffstat (limited to 'Utility/FileMode.hs')
-rw-r--r-- | Utility/FileMode.hs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs index 201b8451c..fdf1b56ba 100644 --- a/Utility/FileMode.hs +++ b/Utility/FileMode.hs @@ -22,15 +22,12 @@ import Utility.Exception {- Applies a conversion function to a file's mode. -} modifyFileMode :: FilePath -> (FileMode -> FileMode) -> IO () -modifyFileMode f convert = void $ modifyFileMode' f convert -modifyFileMode' :: FilePath -> (FileMode -> FileMode) -> IO FileMode -modifyFileMode' f convert = do +modifyFileMode f convert = do s <- getFileStatus f let old = fileMode s let new = convert old when (new /= old) $ setFileMode f new - return old {- Adds the specified FileModes to the input mode, leaving the rest - unchanged. -} @@ -41,14 +38,6 @@ addModes ms m = combineModes (m:ms) removeModes :: [FileMode] -> FileMode -> FileMode removeModes ms m = m `intersectFileModes` complement (combineModes ms) -{- Runs an action after changing a file's mode, then restores the old mode. -} -withModifiedFileMode :: FilePath -> (FileMode -> FileMode) -> IO a -> IO a -withModifiedFileMode file convert a = bracket setup cleanup go - where - setup = modifyFileMode' file convert - cleanup oldmode = modifyFileMode file (const oldmode) - go _ = a - writeModes :: [FileMode] writeModes = [ownerWriteMode, groupWriteMode, otherWriteMode] |