diff options
author | 2016-03-11 12:21:26 -0400 | |
---|---|---|
committer | 2016-03-11 12:21:26 -0400 | |
commit | b15ce31aa84ac2ae3d78e82868fb6065f15c99a4 (patch) | |
tree | 2d547c505b65e23c2e0083098f1f860782a36dfb /Annex | |
parent | 028916acae51217b27de59d19f70ecc24cc2ed36 (diff) | |
parent | f0f17dd7ff1b6220526a9c42683d7c6272598f64 (diff) |
Merge branch 'master' into adjustedbranch
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 44 | ||||
-rw-r--r-- | Annex/Ingest.hs | 12 | ||||
-rw-r--r-- | Annex/Perms.hs | 55 |
3 files changed, 54 insertions, 57 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 103fa264d..9c4c1d5b8 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -41,8 +41,6 @@ module Annex.Content ( saveState, downloadUrl, preseedTmp, - freezeContent, - thawContent, dirKeys, withObjectLoc, staleKeysPrune, @@ -67,7 +65,6 @@ import Utility.CopyFile import Utility.Metered import Config import Git.FilePath -import Git.SharedRepository import Annex.Perms import Annex.Link import qualified Annex.Content.Direct as Direct @@ -917,47 +914,6 @@ preseedTmp key file = go =<< inAnnex key ) ) -{- Normally, blocks writing to an annexed file, and modifies file - - permissions to allow reading it. - - - - When core.sharedRepository is set, the write bits are not removed from - - the file, but instead the appropriate group write bits are set. This is - - necessary to let other users in the group lock the file. - -} -freezeContent :: FilePath -> Annex () -freezeContent file = unlessM crippledFileSystem $ - withShared go - where - go GroupShared = liftIO $ modifyFileMode file $ - addModes [ownerReadMode, groupReadMode, ownerWriteMode, groupWriteMode] - go AllShared = liftIO $ modifyFileMode file $ - addModes (readModes ++ writeModes) - go _ = liftIO $ modifyFileMode file $ - removeModes writeModes . - addModes [ownerReadMode] - -{- Adjusts read mode of annexed file per core.sharedRepository setting. -} -chmodContent :: FilePath -> Annex () -chmodContent file = unlessM crippledFileSystem $ - withShared go - where - go GroupShared = liftIO $ modifyFileMode file $ - addModes [ownerReadMode, groupReadMode] - go AllShared = liftIO $ modifyFileMode file $ - addModes readModes - go _ = liftIO $ modifyFileMode file $ - addModes [ownerReadMode] - -{- Allows writing to an annexed file that freezeContent was called on - - before. -} -thawContent :: FilePath -> Annex () -thawContent file = unlessM crippledFileSystem $ - withShared go - where - go GroupShared = liftIO $ groupWriteRead file - go AllShared = liftIO $ groupWriteRead file - go _ = liftIO $ allowWrite file - {- Finds files directly inside a directory like gitAnnexBadDir - (not in subdirectories) and returns the corresponding keys. -} dirKeys :: (Git.Repo -> FilePath) -> Annex [Key] diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index a7f36466f..b80f0e1e0 100644 --- a/Annex/Ingest.hs +++ b/Annex/Ingest.hs @@ -5,8 +5,6 @@ - Licensed under the GNU GPL version 3 or higher. -} -{-# LANGUAGE CPP #-} - module Annex.Ingest ( LockedDown(..), LockDownConfig(..), @@ -42,13 +40,9 @@ import Utility.InodeCache import Annex.ReplaceFile import Utility.Tmp import Utility.CopyFile +import Utility.Touch import Git.FilePath import Annex.InodeSentinal -#ifdef WITH_CLIBS -#ifndef __ANDROID__ -import Utility.Touch -#endif -#endif import Control.Exception (IOException) @@ -282,11 +276,7 @@ makeLink file key mcache = flip catchNonAsync (restoreFile file key) $ do -- touch symlink to have same time as the original file, -- as provided in the InodeCache case mcache of -#if defined(WITH_CLIBS) && ! defined(__ANDROID__) Just c -> liftIO $ touch file (TimeSpec $ inodeCacheToMtime c) False -#else - Just _ -> noop -#endif Nothing -> noop return l diff --git a/Annex/Perms.hs b/Annex/Perms.hs index 159cc328a..4d525c127 100644 --- a/Annex/Perms.hs +++ b/Annex/Perms.hs @@ -11,6 +11,9 @@ module Annex.Perms ( annexFileMode, createAnnexDirectory, noUmask, + freezeContent, + thawContent, + chmodContent, createContentDir, freezeContentDir, thawContentDir, @@ -77,6 +80,55 @@ createAnnexDirectory dir = walk dir [] =<< top liftIO $ createDirectoryIfMissing True p setAnnexDirPerm p +{- Normally, blocks writing to an annexed file, and modifies file + - permissions to allow reading it. + - + - When core.sharedRepository is set, the write bits are not removed from + - the file, but instead the appropriate group write bits are set. This is + - necessary to let other users in the group lock the file. + -} +freezeContent :: FilePath -> Annex () +freezeContent file = unlessM crippledFileSystem $ + withShared go + where + go GroupShared = liftIO $ modifyFileMode file $ + addModes [ownerReadMode, groupReadMode, ownerWriteMode, groupWriteMode] + go AllShared = liftIO $ modifyFileMode file $ + addModes (readModes ++ writeModes) + go _ = liftIO $ modifyFileMode file $ + removeModes writeModes . + addModes [ownerReadMode] + +{- Adjusts read mode of annexed file per core.sharedRepository setting. -} +chmodContent :: FilePath -> Annex () +chmodContent file = unlessM crippledFileSystem $ + withShared go + where + go GroupShared = liftIO $ modifyFileMode file $ + addModes [ownerReadMode, groupReadMode] + go AllShared = liftIO $ modifyFileMode file $ + addModes readModes + go _ = liftIO $ modifyFileMode file $ + addModes [ownerReadMode] + +{- Allows writing to an annexed file that freezeContent was called on + - before. -} +thawContent :: FilePath -> Annex () +thawContent file = thawPerms $ withShared go + where + go GroupShared = liftIO $ groupWriteRead file + go AllShared = liftIO $ groupWriteRead file + go _ = liftIO $ allowWrite file + +{- Runs an action that thaws a file's permissions. This will probably + - fail on a crippled filesystem. But, if file modes are supported on a + - crippled filesystem, the file may be frozen, so try to thaw it. -} +thawPerms :: Annex () -> Annex () +thawPerms a = ifM crippledFileSystem + ( void $ tryNonAsync a + , a + ) + {- Blocks writing to the directory an annexed file is in, to prevent the - file accidentially being deleted. However, if core.sharedRepository - is set, this is not done, since the group must be allowed to delete the @@ -92,8 +144,7 @@ freezeContentDir file = unlessM crippledFileSystem $ go _ = liftIO $ preventWrite dir thawContentDir :: FilePath -> Annex () -thawContentDir file = unlessM crippledFileSystem $ - liftIO $ allowWrite $ parentDir file +thawContentDir file = thawPerms $ liftIO $ allowWrite $ parentDir file {- Makes the directory tree to store an annexed file's content, - with appropriate permissions on each level. -} |