remove unused code
This commit is contained in:
parent
11e3b2397c
commit
e395ba2cb0
1 changed files with 2 additions and 97 deletions
|
@ -6,17 +6,10 @@
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Annex.Content.Direct (
|
module Annex.Content.Direct (
|
||||||
associatedFiles,
|
|
||||||
removeAssociatedFile,
|
|
||||||
removeAssociatedFiles,
|
|
||||||
addAssociatedFile,
|
|
||||||
goodContent,
|
goodContent,
|
||||||
recordedInodeCache,
|
associatedFiles,
|
||||||
updateInodeCache,
|
removeAssociatedFiles,
|
||||||
addInodeCache,
|
|
||||||
sameInodeCache,
|
|
||||||
removeInodeCache,
|
removeInodeCache,
|
||||||
addContentWhenNotPresent,
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Annex.Common
|
import Annex.Common
|
||||||
|
@ -48,19 +41,6 @@ associatedFilesRelative key = do
|
||||||
-- (Especially needed on Windows.)
|
-- (Especially needed on Windows.)
|
||||||
lines <$> hGetContentsStrict h
|
lines <$> hGetContentsStrict h
|
||||||
|
|
||||||
{- Changes the associated files information for a key, applying a
|
|
||||||
- transformation to the list. Returns new associatedFiles value. -}
|
|
||||||
changeAssociatedFiles :: Key -> ([FilePath] -> [FilePath]) -> Annex [FilePath]
|
|
||||||
changeAssociatedFiles key transform = do
|
|
||||||
mapping <- calcRepo $ gitAnnexMapping key
|
|
||||||
files <- associatedFilesRelative key
|
|
||||||
let files' = transform files
|
|
||||||
when (files /= files') $
|
|
||||||
modifyContent mapping $
|
|
||||||
writeLogFile mapping $ unlines files'
|
|
||||||
top <- fromRepo Git.repoPath
|
|
||||||
return $ map (top </>) files'
|
|
||||||
|
|
||||||
{- Removes the list of associated files. -}
|
{- Removes the list of associated files. -}
|
||||||
removeAssociatedFiles :: Key -> Annex ()
|
removeAssociatedFiles :: Key -> Annex ()
|
||||||
removeAssociatedFiles key = do
|
removeAssociatedFiles key = do
|
||||||
|
@ -68,38 +48,6 @@ removeAssociatedFiles key = do
|
||||||
modifyContent mapping $
|
modifyContent mapping $
|
||||||
liftIO $ nukeFile 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. -}
|
|
||||||
removeAssociatedFile :: Key -> FilePath -> Annex [FilePath]
|
|
||||||
removeAssociatedFile key file = do
|
|
||||||
fs <- removeAssociatedFileUnchecked key file
|
|
||||||
when (null fs) $
|
|
||||||
logStatus key InfoMissing
|
|
||||||
return fs
|
|
||||||
|
|
||||||
{- Removes an associated file. Returns new associatedFiles value. -}
|
|
||||||
removeAssociatedFileUnchecked :: Key -> FilePath -> Annex [FilePath]
|
|
||||||
removeAssociatedFileUnchecked key file = do
|
|
||||||
file' <- normaliseAssociatedFile file
|
|
||||||
changeAssociatedFiles key $ filter (/= file')
|
|
||||||
|
|
||||||
{- Adds an associated file. Returns new associatedFiles value. -}
|
|
||||||
addAssociatedFile :: Key -> FilePath -> Annex [FilePath]
|
|
||||||
addAssociatedFile key file = do
|
|
||||||
file' <- normaliseAssociatedFile file
|
|
||||||
changeAssociatedFiles key $ \files ->
|
|
||||||
if file' `elem` files
|
|
||||||
then files
|
|
||||||
else file':files
|
|
||||||
|
|
||||||
{- Associated files are always stored relative to the top of the repository.
|
|
||||||
- The input FilePath is relative to the CWD, or is absolute. -}
|
|
||||||
normaliseAssociatedFile :: FilePath -> Annex FilePath
|
|
||||||
normaliseAssociatedFile file = do
|
|
||||||
top <- fromRepo Git.repoPath
|
|
||||||
liftIO $ relPathDirToFile top file
|
|
||||||
|
|
||||||
{- Checks if a file in the tree, associated with a key, has not been modified.
|
{- Checks if a file in the tree, associated with a key, has not been modified.
|
||||||
-
|
-
|
||||||
- To avoid needing to fsck the file's content, which can involve an
|
- To avoid needing to fsck the file's content, which can involve an
|
||||||
|
@ -118,28 +66,6 @@ recordedInodeCache key = withInodeCacheFile key $ \f ->
|
||||||
liftIO $ catchDefaultIO [] $
|
liftIO $ catchDefaultIO [] $
|
||||||
mapMaybe readInodeCache . lines <$> readFileStrict f
|
mapMaybe readInodeCache . lines <$> readFileStrict f
|
||||||
|
|
||||||
{- Caches an inode for a file.
|
|
||||||
-
|
|
||||||
- Anything else already cached is preserved.
|
|
||||||
-}
|
|
||||||
updateInodeCache :: Key -> FilePath -> Annex ()
|
|
||||||
updateInodeCache key file = maybe noop (addInodeCache key)
|
|
||||||
=<< withTSDelta (liftIO . genInodeCache file)
|
|
||||||
|
|
||||||
{- Adds another inode to the cache for a key. -}
|
|
||||||
addInodeCache :: Key -> InodeCache -> Annex ()
|
|
||||||
addInodeCache key cache = do
|
|
||||||
oldcaches <- recordedInodeCache key
|
|
||||||
unlessM (elemInodeCaches cache oldcaches) $
|
|
||||||
writeInodeCache key (cache:oldcaches)
|
|
||||||
|
|
||||||
{- Writes inode cache for a key. -}
|
|
||||||
writeInodeCache :: Key -> [InodeCache] -> Annex ()
|
|
||||||
writeInodeCache key caches = withInodeCacheFile key $ \f ->
|
|
||||||
modifyContent f $
|
|
||||||
liftIO $ writeFile f $
|
|
||||||
unlines $ map showInodeCache caches
|
|
||||||
|
|
||||||
{- Removes an inode cache. -}
|
{- Removes an inode cache. -}
|
||||||
removeInodeCache :: Key -> Annex ()
|
removeInodeCache :: Key -> Annex ()
|
||||||
removeInodeCache key = withInodeCacheFile key $ \f ->
|
removeInodeCache key = withInodeCacheFile key $ \f ->
|
||||||
|
@ -148,24 +74,3 @@ removeInodeCache key = withInodeCacheFile key $ \f ->
|
||||||
|
|
||||||
withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a
|
withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a
|
||||||
withInodeCacheFile key a = a =<< calcRepo (gitAnnexInodeCache key)
|
withInodeCacheFile key a = a =<< calcRepo (gitAnnexInodeCache key)
|
||||||
|
|
||||||
{- Checks if a FileStatus matches the recorded InodeCache of a file. -}
|
|
||||||
sameFileStatus :: Key -> FilePath -> FileStatus -> Annex Bool
|
|
||||||
sameFileStatus key f status = do
|
|
||||||
old <- recordedInodeCache key
|
|
||||||
curr <- withTSDelta $ \delta -> liftIO $ toInodeCache delta f status
|
|
||||||
case (old, curr) of
|
|
||||||
(_, Just c) -> elemInodeCaches c old
|
|
||||||
([], Nothing) -> return True
|
|
||||||
_ -> return False
|
|
||||||
|
|
||||||
{- Copies the contentfile to the associated file, if the associated
|
|
||||||
- file has no content. If the associated file does have content,
|
|
||||||
- even if the content differs, it's left unchanged. -}
|
|
||||||
addContentWhenNotPresent :: Key -> FilePath -> FilePath -> Annex ()
|
|
||||||
addContentWhenNotPresent key contentfile associatedfile = do
|
|
||||||
v <- isAnnexLink associatedfile
|
|
||||||
when (Just key == v) $
|
|
||||||
replaceFile associatedfile $
|
|
||||||
liftIO . void . copyFileExternal CopyAllMetaData contentfile
|
|
||||||
updateInodeCache key associatedfile
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue