fix file mode bug
This commit is contained in:
parent
d19171ed53
commit
cf3fc9b8e9
|
@ -2,6 +2,8 @@ module Propellor.Property.File where
|
||||||
|
|
||||||
import Propellor
|
import Propellor
|
||||||
|
|
||||||
|
import System.Posix.Files
|
||||||
|
|
||||||
type Line = String
|
type Line = String
|
||||||
|
|
||||||
-- | Replaces all the content of a file.
|
-- | Replaces all the content of a file.
|
||||||
|
@ -32,13 +34,19 @@ fileProperty :: Desc -> ([Line] -> [Line]) -> FilePath -> Property
|
||||||
fileProperty desc a f = Property desc $ go =<< doesFileExist f
|
fileProperty desc a f = Property desc $ go =<< doesFileExist f
|
||||||
where
|
where
|
||||||
go True = do
|
go True = do
|
||||||
ls <- lines <$> catchDefaultIO [] (readFile f)
|
ls <- lines <$> readFile f
|
||||||
let ls' = a ls
|
let ls' = a ls
|
||||||
if ls' == ls
|
if ls' == ls
|
||||||
then noChange
|
then noChange
|
||||||
else makeChange $ viaTmp writeFile f (unlines ls')
|
else makeChange $ viaTmp updatefile f (unlines ls')
|
||||||
go False = makeChange $ writeFile f (unlines $ a [])
|
go False = makeChange $ writeFile f (unlines $ a [])
|
||||||
|
|
||||||
|
-- viaTmp makes the temp file mode 600.
|
||||||
|
-- Replicate the original file mode before moving it into place.
|
||||||
|
updatefile f' content = do
|
||||||
|
writeFile f' content
|
||||||
|
getFileStatus f >>= setFileMode f' . fileMode
|
||||||
|
|
||||||
-- | Ensures a directory exists.
|
-- | Ensures a directory exists.
|
||||||
dirExists :: FilePath -> Property
|
dirExists :: FilePath -> Property
|
||||||
dirExists d = check (not <$> doesDirectoryExist d) $ Property (d ++ " exists") $
|
dirExists d = check (not <$> doesDirectoryExist d) $ Property (d ++ " exists") $
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
propellor (0.2.2) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
* Now supports provisioning docker containers with architecture/libraries
|
||||||
|
that do not match the outside host.
|
||||||
|
* Fixed a bug that caused file modes to be set to 600 when propellor
|
||||||
|
modified the file.
|
||||||
|
|
||||||
|
-- Joey Hess <joeyh@debian.org> Fri, 04 Apr 2014 00:06:26 -0400
|
||||||
|
|
||||||
propellor (0.2.1) unstable; urgency=medium
|
propellor (0.2.1) unstable; urgency=medium
|
||||||
|
|
||||||
* First release with Debian package.
|
* First release with Debian package.
|
||||||
|
|
Loading…
Reference in New Issue