Skip to content

Commit 9e86364

Browse files
authored
Merge pull request #3212 from commercialhaskell/7zip-temp-dir
When extracting local GHC from tarball on windows, use temp dir #3188
2 parents 93f3863 + 177d31d commit 9e86364

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ Other enhancements:
218218
on the PATH or shadowed by another entry.
219219
* Allow running tests on tarball created by sdist and upload
220220
[#717](https://github.com/commercialhaskell/stack/issues/717).
221+
* For filesystem setup-info paths, it's no longer assumed that the
222+
directory is writable, instead a temp dir is used. See
223+
[#3188](https://github.com/commercialhaskell/stack/issues/3188).
221224

222225
Bug fixes:
223226

src/Stack/Setup.hs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,26 +1369,19 @@ withUnpackedTarball7z name si archiveFile archiveType msrcDir destDir = do
13691369
TarGz -> return ".gz"
13701370
_ -> throwString $ name ++ " must be a tarball file"
13711371
tarFile <-
1372-
case T.stripSuffix suffix $ T.pack $ toFilePath archiveFile of
1372+
case T.stripSuffix suffix $ T.pack $ toFilePath (filename archiveFile) of
13731373
Nothing -> throwString $ "Invalid " ++ name ++ " filename: " ++ show archiveFile
1374-
Just x -> parseAbsFile $ T.unpack x
1374+
Just x -> parseRelFile $ T.unpack x
13751375
run7z <- setup7z si
13761376
let tmpName = toFilePathNoTrailingSep (dirname destDir) ++ "-tmp"
13771377
ensureDir (parent destDir)
13781378
withRunInIO $ \run -> withTempDir (parent destDir) tmpName $ \tmpDir -> run $ do
13791379
liftIO $ ignoringAbsence (removeDirRecur destDir)
1380-
run7z (parent archiveFile) archiveFile
1381-
run7z tmpDir tarFile
1380+
run7z tmpDir archiveFile
1381+
run7z tmpDir (tmpDir </> tarFile)
13821382
absSrcDir <- case msrcDir of
13831383
Just srcDir -> return $ tmpDir </> srcDir
13841384
Nothing -> expectSingleUnpackedDir archiveFile tmpDir
1385-
removeFile tarFile `catchIO` \e ->
1386-
logWarn (T.concat
1387-
[ "Exception when removing "
1388-
, T.pack $ toFilePath tarFile
1389-
, ": "
1390-
, T.pack $ show e
1391-
])
13921385
renameDir absSrcDir destDir
13931386

13941387
expectSingleUnpackedDir :: (MonadIO m, MonadThrow m) => Path Abs File -> Path Abs Dir -> m (Path Abs Dir)

0 commit comments

Comments
 (0)