some easy createDirectoryUnder conversions
This commit is contained in:
parent
ebbc5004fa
commit
6d58ca94d6
12 changed files with 44 additions and 30 deletions
|
@ -170,13 +170,13 @@ checkDiskSpaceDirectory d k = do
|
|||
|
||||
store :: FilePath -> ChunkConfig -> Key -> L.ByteString -> MeterUpdate -> Annex Bool
|
||||
store d chunkconfig k b p = liftIO $ do
|
||||
void $ tryIO $ createDirectoryIfMissing True tmpdir
|
||||
void $ tryIO $ createDirectoryUnder d tmpdir
|
||||
case chunkconfig of
|
||||
LegacyChunks chunksize -> Legacy.store chunksize finalizeStoreGeneric k b p tmpdir destdir
|
||||
LegacyChunks chunksize -> Legacy.store d chunksize (finalizeStoreGeneric d) k b p tmpdir destdir
|
||||
_ -> do
|
||||
let tmpf = tmpdir </> kf
|
||||
meteredWriteFile p tmpf b
|
||||
finalizeStoreGeneric tmpdir destdir
|
||||
finalizeStoreGeneric d tmpdir destdir
|
||||
return True
|
||||
where
|
||||
tmpdir = addTrailingPathSeparator $ d </> "tmp" </> kf
|
||||
|
@ -187,11 +187,11 @@ store d chunkconfig k b p = liftIO $ do
|
|||
- in the dest directory, moves it into place. Anything already existing
|
||||
- in the dest directory will be deleted. File permissions will be locked
|
||||
- down. -}
|
||||
finalizeStoreGeneric :: FilePath -> FilePath -> IO ()
|
||||
finalizeStoreGeneric tmp dest = do
|
||||
finalizeStoreGeneric :: FilePath -> FilePath -> FilePath -> IO ()
|
||||
finalizeStoreGeneric d tmp dest = do
|
||||
void $ tryIO $ allowWrite dest -- may already exist
|
||||
void $ tryIO $ removeDirectoryRecursive dest -- or not exist
|
||||
createDirectoryIfMissing True (parentDir dest)
|
||||
createDirectoryUnder d (parentDir dest)
|
||||
renameDirectory tmp dest
|
||||
-- may fail on some filesystems
|
||||
void $ tryIO $ do
|
||||
|
@ -267,7 +267,7 @@ checkPresentGeneric' d check = ifM check
|
|||
|
||||
storeExportM :: FilePath -> FilePath -> Key -> ExportLocation -> MeterUpdate -> Annex Bool
|
||||
storeExportM d src _k loc p = liftIO $ catchBoolIO $ do
|
||||
createDirectoryIfMissing True (takeDirectory dest)
|
||||
createDirectoryUnder d (takeDirectory dest)
|
||||
-- Write via temp file so that checkPresentGeneric will not
|
||||
-- see it until it's fully stored.
|
||||
viaTmp (\tmp () -> withMeteredFile src p (L.writeFile tmp)) dest ()
|
||||
|
@ -298,7 +298,7 @@ renameExportM :: FilePath -> Key -> ExportLocation -> ExportLocation -> Annex (M
|
|||
renameExportM d _k oldloc newloc = liftIO $ Just <$> go
|
||||
where
|
||||
go = catchBoolIO $ do
|
||||
createDirectoryIfMissing True (takeDirectory dest)
|
||||
createDirectoryUnder d (takeDirectory dest)
|
||||
renameFile src dest
|
||||
removeExportLocation d oldloc
|
||||
return True
|
||||
|
@ -413,7 +413,7 @@ storeExportWithContentIdentifierM dir src _k loc overwritablecids p =
|
|||
catchIO go (return . Left . show)
|
||||
where
|
||||
go = do
|
||||
liftIO $ createDirectoryIfMissing True destdir
|
||||
liftIO $ createDirectoryUnder dir destdir
|
||||
withTmpFileIn destdir template $ \tmpf tmph -> do
|
||||
liftIO $ withMeteredFile src p (L.hPut tmph)
|
||||
liftIO $ hFlush tmph
|
||||
|
|
|
@ -70,9 +70,9 @@ storeLegacyChunked' meterupdate chunksize (d:dests) bs c = do
|
|||
feed bytes' (sz - s) ls h
|
||||
else return (l:ls)
|
||||
|
||||
storeHelper :: (FilePath -> FilePath -> IO ()) -> Key -> ([FilePath] -> IO [FilePath]) -> FilePath -> FilePath -> IO Bool
|
||||
storeHelper finalizer key storer tmpdir destdir = do
|
||||
void $ liftIO $ tryIO $ createDirectoryIfMissing True tmpdir
|
||||
storeHelper :: FilePath -> (FilePath -> FilePath -> IO ()) -> Key -> ([FilePath] -> IO [FilePath]) -> FilePath -> FilePath -> IO Bool
|
||||
storeHelper repotop finalizer key storer tmpdir destdir = do
|
||||
void $ liftIO $ tryIO $ createDirectoryUnder repotop tmpdir
|
||||
Legacy.storeChunks key tmpdir destdir storer recorder finalizer
|
||||
where
|
||||
recorder f s = do
|
||||
|
@ -80,8 +80,8 @@ storeHelper finalizer key storer tmpdir destdir = do
|
|||
writeFile f s
|
||||
void $ tryIO $ preventWrite f
|
||||
|
||||
store :: ChunkSize -> (FilePath -> FilePath -> IO ()) -> Key -> L.ByteString -> MeterUpdate -> FilePath -> FilePath -> IO Bool
|
||||
store chunksize finalizer k b p = storeHelper finalizer k $ \dests ->
|
||||
store :: FilePath -> ChunkSize -> (FilePath -> FilePath -> IO ()) -> Key -> L.ByteString -> MeterUpdate -> FilePath -> FilePath -> IO Bool
|
||||
store repotop chunksize finalizer k b p = storeHelper repotop finalizer k $ \dests ->
|
||||
storeLegacyChunked p chunksize dests b
|
||||
|
||||
{- Need to get a single ByteString containing every chunk.
|
||||
|
|
|
@ -372,7 +372,7 @@ store' repo r rsyncopts
|
|||
let tmpf = tmpdir </> fromRawFilePath (keyFile k)
|
||||
meteredWriteFile p tmpf b
|
||||
let destdir = parentDir $ gCryptLocation repo k
|
||||
Remote.Directory.finalizeStoreGeneric tmpdir destdir
|
||||
Remote.Directory.finalizeStoreGeneric (Git.repoLocation repo) tmpdir destdir
|
||||
return True
|
||||
| Git.repoIsSsh repo = if accessShell r
|
||||
then fileStorer $ \k f p -> do
|
||||
|
|
|
@ -48,7 +48,7 @@ runHooks r starthook stophook a = do
|
|||
dir <- fromRepo gitAnnexRemotesDir
|
||||
let lck = dir </> remoteid ++ ".lck"
|
||||
whenM (notElem lck . M.keys <$> getLockCache) $ do
|
||||
liftIO $ createDirectoryIfMissing True dir
|
||||
createAnnexDirectory dir
|
||||
firstrun lck
|
||||
a
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue