summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-06 16:42:40 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-06 16:42:40 -0400
commita279c22dbcddee19d14a1b492d8d996fef0e3e3d (patch)
tree905a29d5823a9e93a6152d55e24ac4d74e718506
parent81986f63d47e0618d403feb1bfe77611131bbeac (diff)
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.
-rw-r--r--Annex/ReplaceFile.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/Annex/ReplaceFile.hs b/Annex/ReplaceFile.hs
index b090da905..b6126ba7e 100644
--- a/Annex/ReplaceFile.hs
+++ b/Annex/ReplaceFile.hs
@@ -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