update
This commit is contained in:
parent
eccfc69f04
commit
9d133270c2
1 changed files with 12 additions and 8 deletions
|
@ -32,8 +32,7 @@ import qualified Data.ByteString.Lazy as L
|
||||||
- When no known associated files exist, returns the gitAnnexLocation. -}
|
- When no known associated files exist, returns the gitAnnexLocation. -}
|
||||||
associatedFiles :: Key -> Annex [FilePath]
|
associatedFiles :: Key -> Annex [FilePath]
|
||||||
associatedFiles key = do
|
associatedFiles key = do
|
||||||
mapping <- inRepo $ gitAnnexMapping key
|
files <- associatedFilesList key
|
||||||
files <- liftIO $ catchDefaultIO [] $ lines <$> readFile mapping
|
|
||||||
if null files
|
if null files
|
||||||
then do
|
then do
|
||||||
l <- inRepo $ gitAnnexLocation key
|
l <- inRepo $ gitAnnexLocation key
|
||||||
|
@ -42,16 +41,21 @@ associatedFiles key = do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
return $ map (top </>) files
|
return $ map (top </>) files
|
||||||
|
|
||||||
|
{- Raw list of files in the tree that are associated with a key. -}
|
||||||
|
associatedFilesList :: Key -> Annex [FilePath]
|
||||||
|
associatedFilesList key = do
|
||||||
|
mapping <- inRepo $ gitAnnexMapping key
|
||||||
|
liftIO $ catchDefaultIO [] $ lines <$> readFile mapping
|
||||||
|
|
||||||
{- Changes the associated files information for a key, applying a
|
{- Changes the associated files information for a key, applying a
|
||||||
- transformation to the list. -}
|
- transformation to the list. -}
|
||||||
changeAssociatedFiles :: Key -> ([FilePath] -> [FilePath]) -> Annex ()
|
changeAssociatedFiles :: Key -> ([FilePath] -> [FilePath]) -> Annex ()
|
||||||
changeAssociatedFiles key transform = do
|
changeAssociatedFiles key transform = do
|
||||||
mapping <- inRepo $ gitAnnexMapping key
|
mapping <- inRepo $ gitAnnexMapping key
|
||||||
liftIO $ do
|
files <- associatedFilesList key
|
||||||
files <- catchDefaultIO [] $ lines <$> readFile mapping
|
|
||||||
let files' = transform files
|
let files' = transform files
|
||||||
when (files /= files') $
|
when (files /= files') $
|
||||||
viaTmp writeFile mapping $ unlines files'
|
liftIO $ viaTmp writeFile mapping $ unlines files'
|
||||||
|
|
||||||
removeAssociatedFile :: Key -> FilePath -> Annex ()
|
removeAssociatedFile :: Key -> FilePath -> Annex ()
|
||||||
removeAssociatedFile key file = changeAssociatedFiles key $ filter (/= file)
|
removeAssociatedFile key file = changeAssociatedFiles key $ filter (/= file)
|
||||||
|
@ -63,7 +67,7 @@ addAssociatedFile key file = changeAssociatedFiles key $ \files ->
|
||||||
else file:files
|
else file:files
|
||||||
|
|
||||||
{- Uses git diff-tree to find files changed between two tree Shas, and
|
{- Uses git diff-tree to find files changed between two tree Shas, and
|
||||||
- updates the associated file mappings, efficiently -}
|
- updates the associated file mappings, efficiently. -}
|
||||||
updateAssociatedFiles :: Git.Sha -> Git.Sha -> Annex ()
|
updateAssociatedFiles :: Git.Sha -> Git.Sha -> Annex ()
|
||||||
updateAssociatedFiles oldsha newsha = do
|
updateAssociatedFiles oldsha newsha = do
|
||||||
(items, cleanup) <- inRepo $ DiffTree.diffTree oldsha newsha
|
(items, cleanup) <- inRepo $ DiffTree.diffTree oldsha newsha
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue