avoid too long temp dir template
authorJoey Hess <joeyh@joeyh.name>
Sun, 6 Dec 2015 20:42:40 +0000 (16:42 -0400)
committerJoey Hess <joeyh@joeyh.name>
Sun, 6 Dec 2015 20:42:40 +0000 (16:42 -0400)
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.

Annex/ReplaceFile.hs

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