avoid too long temp dir template

The filename might be at or close to the filename length limit, so using it
as the template for the temp dir would then fail.
This commit is contained in:
Joey Hess 2015-12-06 16:42:40 -04:00
parent 969d54f914
commit 6e71094e7d
Failed to extract signature

View file

@ -27,7 +27,8 @@ replaceFile :: FilePath -> (FilePath -> Annex ()) -> Annex ()
replaceFile file action = do replaceFile file action = do
misctmpdir <- fromRepo gitAnnexTmpMiscDir misctmpdir <- fromRepo gitAnnexTmpMiscDir
void $ createAnnexDirectory misctmpdir void $ createAnnexDirectory misctmpdir
let basetmp = takeFileName file filemax <- liftIO $ fileNameLengthLimit misctmpdir
let basetmp = take (filemax `div` 2) (takeFileName file)
withTmpDirIn misctmpdir basetmp $ \tmpdir -> do withTmpDirIn misctmpdir basetmp $ \tmpdir -> do
let tmpfile = tmpdir <> basetmp let tmpfile = tmpdir <> basetmp
action tmpfile action tmpfile