@@ -65,7 +65,7 @@ import Network.HTTP.StackClient
65
65
)
66
66
import Network.HTTP.Simple ( getResponseHeader )
67
67
import Path
68
- ( (</>) , addExtension , dirname , filename , parent , parseAbsDir
68
+ ( (</>) , addExtension , filename , parent , parseAbsDir
69
69
, parseAbsFile , parseRelDir , parseRelFile , toFilePath
70
70
)
71
71
import Path.CheckInstall ( warnInstallSearchPathIssues )
@@ -74,7 +74,7 @@ import Path.Extra ( toFilePathNoTrailingSep )
74
74
import Path.IO
75
75
( canonicalizePath , doesFileExist , ensureDir , executable
76
76
, getPermissions , ignoringAbsence , listDir , removeDirRecur
77
- , renameDir , renameFile , resolveFile' , withTempDir
77
+ , renameDir , renameFile , resolveFile'
78
78
)
79
79
import RIO.List
80
80
( headMaybe , intercalate , intersperse , isPrefixOf
@@ -2322,12 +2322,16 @@ withUnpackedTarball7z name si archiveFile archiveType destDir = do
2322
2322
Nothing -> prettyThrowIO $ TarballFileInvalid name archiveFile
2323
2323
Just x -> parseRelFile $ T. unpack x
2324
2324
run7z <- setup7z si
2325
- -- Truncate the name of the temporary directory, to reduce risk of Windows'
2326
- -- default file path length of 260 characters being exceeded.
2327
- let tmpName = take 15 (toFilePathNoTrailingSep (dirname destDir)) ++ " -tmp"
2325
+ -- We use a short name for the temporary directory to reduce the risk of a
2326
+ -- filepath length of more than 260 characters, which can be problematic for
2327
+ -- 7-Zip even if Long Filepaths are enabled on Windows.
2328
+ let tmpName = " tmp"
2328
2329
ensureDir (parent destDir)
2329
2330
withRunInIO $ \ run ->
2330
- withTempDir (parent destDir) tmpName $ \ tmpDir ->
2331
+ -- We use the system temporary directory to reduce the risk of a filepath
2332
+ -- length of more than 260 characters, which can be problematic for
2333
+ -- 7-Zip even if Long Filepaths are enabled on Windows.
2334
+ withSystemTempDir tmpName $ \ tmpDir ->
2331
2335
run $ do
2332
2336
liftIO $ ignoringAbsence (removeDirRecur destDir)
2333
2337
run7z tmpDir archiveFile
@@ -2340,8 +2344,8 @@ expectSingleUnpackedDir ::
2340
2344
=> Path Abs File
2341
2345
-> Path Abs Dir
2342
2346
-> m (Path Abs Dir )
2343
- expectSingleUnpackedDir archiveFile destDir = do
2344
- contents <- listDir destDir
2347
+ expectSingleUnpackedDir archiveFile unpackDir = do
2348
+ contents <- listDir unpackDir
2345
2349
case contents of
2346
2350
([dir], _ ) -> pure dir
2347
2351
_ -> prettyThrowIO $ UnknownArchiveStructure archiveFile
0 commit comments