diff options
Diffstat (limited to 'Annex/Content')
-rw-r--r-- | Annex/Content/Direct.hs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Annex/Content/Direct.hs b/Annex/Content/Direct.hs index b0b8621e9..a5d71288b 100644 --- a/Annex/Content/Direct.hs +++ b/Annex/Content/Direct.hs @@ -10,6 +10,7 @@ module Annex.Content.Direct ( associatedFilesRelative, removeAssociatedFile, removeAssociatedFileUnchecked, + removeAssociatedFiles, addAssociatedFile, goodContent, recordedInodeCache, @@ -64,8 +65,8 @@ changeAssociatedFiles key transform = do files <- associatedFilesRelative key let files' = transform files when (files /= files') $ do - createContentDir mapping - liftIO $ viaTmp write mapping $ unlines files' + modifyContent mapping $ + liftIO $ viaTmp write mapping $ unlines files' top <- fromRepo Git.repoPath return $ map (top </>) files' where @@ -75,6 +76,13 @@ changeAssociatedFiles key transform = do hPutStr h content hClose h +{- Removes the list of associated files. -} +removeAssociatedFiles :: Key -> Annex () +removeAssociatedFiles key = do + mapping <- calcRepo $ gitAnnexMapping key + modifyContent mapping $ + liftIO $ nukeFile mapping + {- Removes an associated file. Returns new associatedFiles value. - Checks if this was the last copy of the object, and updates location - log. -} @@ -142,16 +150,16 @@ addInodeCache key cache = do {- Writes inode cache for a key. -} writeInodeCache :: Key -> [InodeCache] -> Annex () -writeInodeCache key caches = withInodeCacheFile key $ \f -> do - createContentDir f - liftIO $ writeFile f $ - unlines $ map showInodeCache caches +writeInodeCache key caches = withInodeCacheFile key $ \f -> + modifyContent f $ + liftIO $ writeFile f $ + unlines $ map showInodeCache caches {- Removes an inode cache. -} removeInodeCache :: Key -> Annex () -removeInodeCache key = withInodeCacheFile key $ \f -> do - createContentDir f -- also thaws directory - liftIO $ nukeFile f +removeInodeCache key = withInodeCacheFile key $ \f -> + modifyContent f $ + liftIO $ nukeFile f withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a withInodeCacheFile key a = a =<< calcRepo (gitAnnexInodeCache key) |