summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-04 15:46:33 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-04 15:46:33 -0400
commita7cc06b30d3ae8a9801a68729db23dd66f8dadf6 (patch)
treeb500f785b37815cf82d82da299881e07931ab27c /Annex
parent307212395c912ab268109521ceae1bf192f728d8 (diff)
Use lower case hash directories for storing files on crippled filesystems, same as is already done for bare repositories.
* since this is a crippled filesystem anyway, git-annex doesn't use symlinks on it * so there's no reason to use the mixed case hash directories that we're stuck using to avoid breaking everyone's symlinks to the content * so we can do what is already done for all bare repos, and make non-bare repos on crippled filesystems use the all-lower case hash directories * which are, happily, all 3 letters long, so they cannot conflict with mixed case hash directories * so I was able to 100% fix this and even resuming `git annex add` in the test case will recover and it will all just work.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Content.hs27
-rw-r--r--Annex/Content/Direct.hs6
-rw-r--r--Annex/Direct.hs7
3 files changed, 15 insertions, 25 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index 8eddae325..44e5bb106 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -9,7 +9,6 @@ module Annex.Content (
inAnnex,
inAnnexSafe,
lockContent,
- calcGitLink,
getViaTmp,
getViaTmpChecked,
getViaTmpUnchecked,
@@ -101,7 +100,7 @@ inAnnexSafe = inAnnex' (fromMaybe False) (Just False) go
- it. (If the content is not present, no locking is done.) -}
lockContent :: Key -> Annex a -> Annex a
lockContent key a = do
- file <- inRepo $ gitAnnexLocation key
+ file <- calcRepo $ gitAnnexLocation key
bracketIO (openforlock file >>= lock) unlock a
where
{- Since files are stored with the write bit disabled, have
@@ -123,16 +122,6 @@ lockContent key a = do
unlock Nothing = noop
unlock (Just l) = closeFd l
-{- Calculates the relative path to use to link a file to a key. -}
-calcGitLink :: FilePath -> Key -> Annex FilePath
-calcGitLink file key = do
- cwd <- liftIO getCurrentDirectory
- let absfile = fromMaybe whoops $ absNormPath cwd file
- loc <- inRepo $ gitAnnexLocation key
- return $ relPathDirToFile (parentDir absfile) loc
- where
- whoops = error $ "unable to normalize " ++ file
-
{- Runs an action, passing it a temporary filename to get,
- and if the action succeeds, moves the temp file into
- the annex as a key's content. -}
@@ -251,7 +240,7 @@ moveAnnex key src = withObjectLoc key storeobject storedirect
storedirect fs = storedirect' =<< filterM validsymlink fs
validsymlink f = (==) (Just key) <$> isAnnexLink f
- storedirect' [] = storeobject =<< inRepo (gitAnnexLocation key)
+ storedirect' [] = storeobject =<< calcRepo (gitAnnexLocation key)
storedirect' (dest:fs) = do
updateInodeCache key src
thawContent src
@@ -341,11 +330,11 @@ withObjectLoc key indirect direct = ifM isDirect
, goindirect
)
where
- goindirect = indirect =<< inRepo (gitAnnexLocation key)
+ goindirect = indirect =<< calcRepo (gitAnnexLocation key)
cleanObjectLoc :: Key -> Annex ()
cleanObjectLoc key = do
- file <- inRepo $ gitAnnexLocation key
+ file <- calcRepo $ gitAnnexLocation key
unlessM crippledFileSystem $
void $ liftIO $ catchMaybeIO $ allowWrite $ parentDir file
liftIO $ removeparents file (3 :: Int)
@@ -374,7 +363,7 @@ removeAnnex key = withObjectLoc key remove removedirect
removeInodeCache key
mapM_ (resetfile cache) fs
resetfile cache f = whenM (sameInodeCache f cache) $ do
- l <- calcGitLink f key
+ l <- inRepo $ gitAnnexLink f key
top <- fromRepo Git.repoPath
cwd <- liftIO getCurrentDirectory
let top' = fromMaybe top $ absNormPath cwd top
@@ -384,7 +373,7 @@ removeAnnex key = withObjectLoc key remove removedirect
{- Moves a key's file out of .git/annex/objects/ -}
fromAnnex :: Key -> FilePath -> Annex ()
fromAnnex key dest = do
- file <- inRepo $ gitAnnexLocation key
+ file <- calcRepo $ gitAnnexLocation key
unlessM crippledFileSystem $
liftIO $ allowWrite $ parentDir file
thawContent file
@@ -395,7 +384,7 @@ fromAnnex key dest = do
- returns the file it was moved to. -}
moveBad :: Key -> Annex FilePath
moveBad key = do
- src <- inRepo $ gitAnnexLocation key
+ src <- calcRepo $ gitAnnexLocation key
bad <- fromRepo gitAnnexBadDir
let dest = bad </> takeFileName src
createAnnexDirectory (parentDir dest)
@@ -468,7 +457,7 @@ preseedTmp key file = go =<< inAnnex key
copy = ifM (liftIO $ doesFileExist file)
( return True
, do
- s <- inRepo $ gitAnnexLocation key
+ s <- calcRepo $ gitAnnexLocation key
liftIO $ copyFileExternal s file
)
diff --git a/Annex/Content/Direct.hs b/Annex/Content/Direct.hs
index 25e257918..1f9ddb784 100644
--- a/Annex/Content/Direct.hs
+++ b/Annex/Content/Direct.hs
@@ -42,7 +42,7 @@ associatedFiles key = do
- the top of the repo. -}
associatedFilesRelative :: Key -> Annex [FilePath]
associatedFilesRelative key = do
- mapping <- inRepo $ gitAnnexMapping key
+ mapping <- calcRepo $ gitAnnexMapping key
liftIO $ catchDefaultIO [] $ do
h <- openFile mapping ReadMode
fileEncoding h
@@ -52,7 +52,7 @@ associatedFilesRelative key = do
- transformation to the list. Returns new associatedFiles value. -}
changeAssociatedFiles :: Key -> ([FilePath] -> [FilePath]) -> Annex [FilePath]
changeAssociatedFiles key transform = do
- mapping <- inRepo $ gitAnnexMapping key
+ mapping <- calcRepo $ gitAnnexMapping key
files <- associatedFilesRelative key
let files' = transform files
when (files /= files') $ do
@@ -124,7 +124,7 @@ removeInodeCache key = withInodeCacheFile key $ \f -> do
liftIO $ nukeFile f
withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a
-withInodeCacheFile key a = a =<< inRepo (gitAnnexInodeCache key)
+withInodeCacheFile key a = a =<< calcRepo (gitAnnexInodeCache key)
{- Checks if a InodeCache matches the current version of a file. -}
sameInodeCache :: FilePath -> Maybe InodeCache -> Annex Bool
diff --git a/Annex/Direct.hs b/Annex/Direct.hs
index 7836ceb96..e3779adc8 100644
--- a/Annex/Direct.hs
+++ b/Annex/Direct.hs
@@ -89,7 +89,8 @@ addDirect file cache = do
return False
got (Just (key, _)) = ifM (sameInodeCache file $ Just cache)
( do
- stageSymlink file =<< hashSymlink =<< calcGitLink file key
+ l <- inRepo $ gitAnnexLink file key
+ stageSymlink file =<< hashSymlink l
writeInodeCache key cache
void $ addAssociatedFile key file
logStatus key InfoPresent
@@ -152,7 +153,7 @@ mergeDirectCleanup d oldsha newsha = do
-
- Symlinks are replaced with their content, if it's available. -}
movein k f = do
- l <- calcGitLink f k
+ l <- inRepo $ gitAnnexLink f k
replaceFile f $ makeAnnexLink l
toDirect k f
@@ -169,7 +170,7 @@ toDirect k f = fromMaybe noop =<< toDirectGen k f
toDirectGen :: Key -> FilePath -> Annex (Maybe (Annex ()))
toDirectGen k f = do
- loc <- inRepo $ gitAnnexLocation k
+ loc <- calcRepo $ gitAnnexLocation k
absf <- liftIO $ absPath f
locs <- filter (/= absf) <$> addAssociatedFile k f
case locs of