avoid crashing on Android when file mode of .git/annex/url cannot be set
Presumably, if the filesystem doesn't support file permissions, it's not much of a multiuser system.
This commit is contained in:
parent
04e0a42093
commit
c96ff106d0
2 changed files with 10 additions and 3 deletions
|
@ -10,6 +10,7 @@ module Utility.FileMode where
|
|||
import Common
|
||||
|
||||
import Control.Exception (bracket)
|
||||
import Utility.Exception
|
||||
import System.Posix.Types
|
||||
import Foreign (complement)
|
||||
|
||||
|
@ -103,10 +104,16 @@ setSticky :: FilePath -> IO ()
|
|||
setSticky f = modifyFileMode f $ addModes [stickyMode]
|
||||
|
||||
{- Writes a file, ensuring that its modes do not allow it to be read
|
||||
- by anyone other than the current user, before any content is written. -}
|
||||
- by anyone other than the current user, before any content is written.
|
||||
-
|
||||
- On a filesystem that does not support file permissions, this is the same
|
||||
- as writeFile.
|
||||
-}
|
||||
writeFileProtected :: FilePath -> String -> IO ()
|
||||
writeFileProtected file content = do
|
||||
h <- openFile file WriteMode
|
||||
modifyFileMode file $ removeModes [groupReadMode, otherReadMode]
|
||||
void $ tryIO $
|
||||
modifyFileMode file $
|
||||
removeModes [groupReadMode, otherReadMode]
|
||||
hPutStr h content
|
||||
hClose h
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Name: git-annex
|
||||
Version: 4.20130501
|
||||
Version: 4.20130502
|
||||
Cabal-Version: >= 1.8
|
||||
License: GPL
|
||||
Maintainer: Joey Hess <joey@kitenet.net>
|
||||
|
|
Loading…
Reference in a new issue