From cd8e2e4eeb70d22f9a7daa375474d80aa188574b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 15 Feb 2016 11:47:33 -0400 Subject: move old ghc compat code into separate module; eliminate WITH_CLIBS This avoids hsc2hs being run except when building for the old version of ghc. Should speed up builds. --- Annex/Ingest.hs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'Annex') diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index 0dd8b5967..68db3eef0 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(..), @@ -38,13 +36,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) @@ -260,11 +254,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 -- cgit v1.2.3 From 0e37e9778f38bfec13fb8bbd2f5e1e3323179fe4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 9 Mar 2016 13:33:13 -0400 Subject: Always try to thaw content, even when annex.crippledfilesystem is set. --- Annex/Content.hs | 9 +++++++-- Annex/Perms.hs | 11 +++++++++-- debian/changelog | 1 + doc/bugs/git-annex:_failed_to_lock_content.mdwn | 2 ++ .../comment_6_ced3c56607762562c1d21fd821d7c779._comment | 11 +++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 doc/bugs/git-annex:_failed_to_lock_content/comment_6_ced3c56607762562c1d21fd821d7c779._comment (limited to 'Annex') diff --git a/Annex/Content.hs b/Annex/Content.hs index 103fa264d..d14e87adc 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -951,8 +951,13 @@ chmodContent file = unlessM crippledFileSystem $ {- Allows writing to an annexed file that freezeContent was called on - before. -} thawContent :: FilePath -> Annex () -thawContent file = unlessM crippledFileSystem $ - withShared go +thawContent file = ifM crippledFileSystem + -- Probably cannot change mode on crippled filesystem, + -- but if file modes are supported, the content may be frozen + -- so try to thaw it. + ( void $ tryNonAsync $ withShared go + , withShared go + ) where go GroupShared = liftIO $ groupWriteRead file go AllShared = liftIO $ groupWriteRead file diff --git a/Annex/Perms.hs b/Annex/Perms.hs index 159cc328a..3905b7af9 100644 --- a/Annex/Perms.hs +++ b/Annex/Perms.hs @@ -92,8 +92,15 @@ freezeContentDir file = unlessM crippledFileSystem $ go _ = liftIO $ preventWrite dir thawContentDir :: FilePath -> Annex () -thawContentDir file = unlessM crippledFileSystem $ - liftIO $ allowWrite $ parentDir file +thawContentDir file = ifM crippledFileSystem + -- Probably cannot change mode on crippled filesystem, + -- but if file modes are supported, the directory may be frozen, + -- so try to thaw it. + ( void $ tryNonAsync go + , go + ) + where + go = liftIO $ allowWrite $ parentDir file {- Makes the directory tree to store an annexed file's content, - with appropriate permissions on each level. -} diff --git a/debian/changelog b/debian/changelog index fe8d0cb1a..fc01dbdaf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ git-annex (6.20160230) UNRELEASED; urgency=medium * dropkey: Add --batch and --json. * Fix OSX dmg to include libraries needed by bundled gpg, lost in last release. + * Always try to thaw content, even when annex.crippledfilesystem is set. -- Joey Hess Mon, 29 Feb 2016 13:00:30 -0400 diff --git a/doc/bugs/git-annex:_failed_to_lock_content.mdwn b/doc/bugs/git-annex:_failed_to_lock_content.mdwn index f383f30ff..f036f1353 100644 --- a/doc/bugs/git-annex:_failed_to_lock_content.mdwn +++ b/doc/bugs/git-annex:_failed_to_lock_content.mdwn @@ -103,3 +103,5 @@ Could the problem have something to do with the file having permission 0444 and ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) Been using it since your kickstarter campaign! + +> [[done]] --[[Joey]] diff --git a/doc/bugs/git-annex:_failed_to_lock_content/comment_6_ced3c56607762562c1d21fd821d7c779._comment b/doc/bugs/git-annex:_failed_to_lock_content/comment_6_ced3c56607762562c1d21fd821d7c779._comment new file mode 100644 index 000000000..cebc1f0c1 --- /dev/null +++ b/doc/bugs/git-annex:_failed_to_lock_content/comment_6_ced3c56607762562c1d21fd821d7c779._comment @@ -0,0 +1,11 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 6""" + date="2016-03-09T17:31:18Z" + content=""" +Ok, I managed to get a vfat that honors file perms with those mount +options. + +I'm going to make git-annex always try to chmod the file, even if it's on a +crippled filesystem. That should solve it. +"""]] -- cgit v1.2.3 From 45db841c7c5602f73796836fb9203bf0a962050d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 9 Mar 2016 13:43:22 -0400 Subject: refactor --- Annex/Content.hs | 49 ------------------------------------------ Annex/Perms.hs | 62 ++++++++++++++++++++++++++++++++++++++++++++++-------- Command/Unannex.hs | 1 + Command/Unlock.hs | 1 + 4 files changed, 55 insertions(+), 58 deletions(-) (limited to 'Annex') diff --git a/Annex/Content.hs b/Annex/Content.hs index d14e87adc..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,52 +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 = ifM crippledFileSystem - -- Probably cannot change mode on crippled filesystem, - -- but if file modes are supported, the content may be frozen - -- so try to thaw it. - ( void $ tryNonAsync $ withShared go - , 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/Perms.hs b/Annex/Perms.hs index 3905b7af9..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,15 +144,7 @@ freezeContentDir file = unlessM crippledFileSystem $ go _ = liftIO $ preventWrite dir thawContentDir :: FilePath -> Annex () -thawContentDir file = ifM crippledFileSystem - -- Probably cannot change mode on crippled filesystem, - -- but if file modes are supported, the directory may be frozen, - -- so try to thaw it. - ( void $ tryNonAsync go - , go - ) - where - go = 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. -} diff --git a/Command/Unannex.hs b/Command/Unannex.hs index 9e6044109..f01d2b219 100644 --- a/Command/Unannex.hs +++ b/Command/Unannex.hs @@ -13,6 +13,7 @@ import Command import Config import qualified Annex import Annex.Content +import Annex.Perms import Annex.Content.Direct import Annex.Version import qualified Git.Command diff --git a/Command/Unlock.hs b/Command/Unlock.hs index ded44fd2f..ac99d5cd3 100644 --- a/Command/Unlock.hs +++ b/Command/Unlock.hs @@ -9,6 +9,7 @@ module Command.Unlock where import Command import Annex.Content +import Annex.Perms import Annex.CatFile import Annex.Version import Annex.Link -- cgit v1.2.3