diff options
author | Joey Hess <joeyh@joeyh.name> | 2018-01-02 17:17:10 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2018-01-02 17:25:25 -0400 |
commit | ed2c1839fd8e0616165de569cff939dc3bf6527d (patch) | |
tree | 7dd4eed72c8a32ccd53f8bb75620e205eba514a5 /Logs/Transfer.hs | |
parent | 2c16edc58f1f549cd4e5611c0f7c45fec6b66da0 (diff) |
Fix several places where files in .git/annex/ were written with modes that did not take the core.sharedRepository config into account.
git grep writeFile finds some more that might also be problems, but
for now I've concentrated on .git/annex/ log files. There are certianly
cases where writeFile is not a problem too.
This commit was sponsored by mo on Patreon.
Diffstat (limited to 'Logs/Transfer.hs')
-rw-r--r-- | Logs/Transfer.hs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs index 3e90ae1ee..9413f703b 100644 --- a/Logs/Transfer.hs +++ b/Logs/Transfer.hs @@ -19,6 +19,7 @@ import Utility.Percentage import Utility.PID import Annex.LockPool import Logs.TimeStamp +import Logs.File import Data.Time.Clock import Data.Time.Clock.POSIX @@ -51,7 +52,7 @@ percentComplete (Transfer { transferKey = key }) info = mkProgressUpdater :: Transfer -> TransferInfo -> Annex (MeterUpdate, FilePath, MVar Integer) mkProgressUpdater t info = do tfile <- fromRepo $ transferFile t - _ <- tryNonAsync $ createAnnexDirectory $ takeDirectory tfile + _ <- tryNonAsync $ writeTransferInfoFile info tfile mvar <- liftIO $ newMVar 0 return (liftIO . updater tfile mvar, tfile, mvar) where @@ -60,7 +61,7 @@ mkProgressUpdater t info = do if newbytes - oldbytes >= mindelta then do let info' = info { bytesComplete = Just newbytes } - _ <- tryIO $ writeTransferInfoFile info' tfile + _ <- tryIO $ updateTransferInfoFile info' tfile return newbytes else return oldbytes {- The minimum change in bytesComplete that is worth @@ -181,8 +182,7 @@ removeFailedTransfer t = do recordFailedTransfer :: Transfer -> TransferInfo -> Annex () recordFailedTransfer t info = do failedtfile <- fromRepo $ failedTransferFile t - createAnnexDirectory $ takeDirectory failedtfile - liftIO $ writeTransferInfoFile info failedtfile + writeTransferInfoFile info failedtfile {- The transfer information file to use for a given Transfer. -} transferFile :: Transfer -> Git.Repo -> FilePath @@ -213,8 +213,13 @@ parseTransferFile file where bits = splitDirectories file -writeTransferInfoFile :: TransferInfo -> FilePath -> IO () -writeTransferInfoFile info tfile = writeFile tfile $ writeTransferInfo info +writeTransferInfoFile :: TransferInfo -> FilePath -> Annex () +writeTransferInfoFile info tfile = writeLogFile tfile $ writeTransferInfo info + +-- The file keeps whatever permissions it has, so should be used only +-- after it's been created with the right perms by writeTransferInfoFile. +updateTransferInfoFile :: TransferInfo -> FilePath -> IO () +updateTransferInfoFile info tfile = writeFile tfile $ writeTransferInfo info {- File format is a header line containing the startedTime and any - bytesComplete value. Followed by a newline and the associatedFile. |