summaryrefslogtreecommitdiff
path: root/Annex/ReplaceFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-06 12:49:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-06 12:49:41 -0400
commit2c0c99eea6ac82e42b46fc9e9c2541736862fd47 (patch)
treef833bbf81f69172bf54f4f7b89452a78742a5a0e /Annex/ReplaceFile.hs
parenta5628f8cfcb44f8a1c2dfe2fd268c7f547ee51b6 (diff)
Windows: Fix an over-long temp directory name.
Diffstat (limited to 'Annex/ReplaceFile.hs')
-rw-r--r--Annex/ReplaceFile.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Annex/ReplaceFile.hs b/Annex/ReplaceFile.hs
index 4b1b2b5db..7cb4fbdea 100644
--- a/Annex/ReplaceFile.hs
+++ b/Annex/ReplaceFile.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Annex.ReplaceFile where
import Annex.Common
@@ -27,8 +29,17 @@ replaceFile :: FilePath -> (FilePath -> Annex ()) -> Annex ()
replaceFile file action = do
misctmpdir <- fromRepo gitAnnexTmpMiscDir
void $ createAnnexDirectory misctmpdir
+#ifndef mingw32_HOST_OS
+ -- Use part of the filename as the template for the temp
+ -- directory. This does not need to be unique, but it
+ -- makes it more clear what this temp directory is for.
filemax <- liftIO $ fileNameLengthLimit misctmpdir
let basetmp = take (filemax `div` 2) (takeFileName file)
+#else
+ -- Windows has limits on the whole path length, so keep
+ -- it short.
+ let basetmp = "t"
+#endif
withTmpDirIn misctmpdir basetmp $ \tmpdir -> do
let tmpfile = tmpdir </> basetmp
action tmpfile