From c1e90767daeff7557e047ea4229d83c4e78f9f12 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Jan 2025 14:23:00 -0400 Subject: [PATCH 1/2] fix FileIO openTempFile on Windows When an UNC-style path is passed into openTempFile, the returned file starts with that same style of path. Which can cause problems, eg piping that filename to git failed. So, convert the output filename to be relative to the input temp directory. --- Utility/FileIO.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Utility/FileIO.hs b/Utility/FileIO.hs index 4b12b2ba0e..6a22025963 100644 --- a/Utility/FileIO.hs +++ b/Utility/FileIO.hs @@ -35,7 +35,9 @@ import System.File.OsPath -- https://github.com/haskell/file-io/issues/39 import Utility.Path.Windows import Utility.OsPath +import System.OsPath import System.IO (IO, Handle, IOMode) +import Prelude (return) import qualified System.File.OsPath as O import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as L @@ -84,7 +86,10 @@ appendFile' f b = do openTempFile :: OsPath -> OsPath -> IO (OsPath, Handle) openTempFile p s = do p' <- toOsPath <$> convertToWindowsNativeNamespace (fromOsPath p) - O.openTempFile p' s + (t, h) <- O.openTempFile p' s + -- Avoid returning mangled path from convertToWindowsNativeNamespace + let t' = p takeFileName t + return (t', h) #endif #else From fb7a0ccb4ced8933be741e41eed1aac8667c4d86 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Jan 2025 14:32:44 -0400 Subject: [PATCH 2/2] Revert "disable OsPath build flag on windows for now" This reverts commit 55cf9ce28fe1c8a4ee64f1843cd3a88e85bcbf35. Problem was fixed by commit c1e90767daeff7557e047ea4229d83c4e78f9f12 --- git-annex.cabal | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/git-annex.cabal b/git-annex.cabal index b610cdf65c..b662fe482e 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -333,14 +333,12 @@ Executable git-annex P2P.Http.State if flag(OsPath) - -- Currently this build flag does not pass the test suite on Windows - if (! os(windows)) - Build-Depends: - os-string (>= 2.0.0), - directory (>= 1.3.8.3), - filepath (>= 1.5.2.0), - file-io (>= 0.1.3) - CPP-Options: -DWITH_OSPATH + Build-Depends: + os-string (>= 2.0.0), + directory (>= 1.3.8.3), + filepath (>= 1.5.2.0), + file-io (>= 0.1.3) + CPP-Options: -DWITH_OSPATH if (os(windows)) Build-Depends: