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 Common
|
||||||
|
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
|
import Utility.Exception
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import Foreign (complement)
|
import Foreign (complement)
|
||||||
|
|
||||||
|
@ -103,10 +104,16 @@ setSticky :: FilePath -> IO ()
|
||||||
setSticky f = modifyFileMode f $ addModes [stickyMode]
|
setSticky f = modifyFileMode f $ addModes [stickyMode]
|
||||||
|
|
||||||
{- Writes a file, ensuring that its modes do not allow it to be read
|
{- 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 :: FilePath -> String -> IO ()
|
||||||
writeFileProtected file content = do
|
writeFileProtected file content = do
|
||||||
h <- openFile file WriteMode
|
h <- openFile file WriteMode
|
||||||
modifyFileMode file $ removeModes [groupReadMode, otherReadMode]
|
void $ tryIO $
|
||||||
|
modifyFileMode file $
|
||||||
|
removeModes [groupReadMode, otherReadMode]
|
||||||
hPutStr h content
|
hPutStr h content
|
||||||
hClose h
|
hClose h
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Name: git-annex
|
Name: git-annex
|
||||||
Version: 4.20130501
|
Version: 4.20130502
|
||||||
Cabal-Version: >= 1.8
|
Cabal-Version: >= 1.8
|
||||||
License: GPL
|
License: GPL
|
||||||
Maintainer: Joey Hess <joey@kitenet.net>
|
Maintainer: Joey Hess <joey@kitenet.net>
|
||||||
|
|
Loading…
Add table
Reference in a new issue