made parentDir return a Maybe FilePath; removed most uses of it
parentDir is less safe than takeDirectory, especially when working with relative FilePaths. It's really only useful in loops that want to terminate at / This commit was sponsored by Audric SCHILTKNECHT.
This commit is contained in:
parent
d09a198ec0
commit
965e106f24
47 changed files with 97 additions and 96 deletions
|
@ -261,7 +261,7 @@ finishGetViaTmp check key action = do
|
|||
prepTmp :: Key -> Annex FilePath
|
||||
prepTmp key = do
|
||||
tmp <- fromRepo $ gitAnnexTmpObjectLocation key
|
||||
createAnnexDirectory (parentDir tmp)
|
||||
createAnnexDirectory (takeDirectory tmp)
|
||||
return tmp
|
||||
|
||||
{- Creates a temp file for a key, runs an action on it, and cleans up
|
||||
|
@ -425,7 +425,7 @@ cleanObjectLoc key cleaner = do
|
|||
where
|
||||
removeparents _ 0 = noop
|
||||
removeparents file n = do
|
||||
let dir = parentDir file
|
||||
let dir = takeDirectory file
|
||||
maybe noop (const $ removeparents dir (n-1))
|
||||
<=< catchMaybeIO $ removeDirectory dir
|
||||
|
||||
|
@ -474,7 +474,7 @@ moveBad key = do
|
|||
src <- calcRepo $ gitAnnexLocation key
|
||||
bad <- fromRepo gitAnnexBadDir
|
||||
let dest = bad </> takeFileName src
|
||||
createAnnexDirectory (parentDir dest)
|
||||
createAnnexDirectory (takeDirectory dest)
|
||||
cleanObjectLoc key $
|
||||
liftIO $ moveFile src dest
|
||||
logStatus key InfoMissing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue