Skip to content

Commit 28fe856

Browse files
authored
Merge pull request #11862 from hasufell/CI-fix-check-pr-labels
Fix check-pr-labels
2 parents 6d67235 + d9b37b8 commit 28fe856

4 files changed

Lines changed: 25 additions & 14 deletions

File tree

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- id: gen_output
3030
run: |
3131
if [ "${{ github.event.action }}" == 'labeled' ] ; then
32-
if [ ${{ github.event.label.name == '${{ env.BUILD_LABEL }}' }} ] ; then
32+
if [ "${{ github.event.label.name }}" == "${{ env.BUILD_LABEL }}" ] ; then
3333
echo run_release_workflow="yes" >> "$GITHUB_OUTPUT"
3434
else
3535
echo run_release_workflow="no" >> "$GITHUB_OUTPUT"

.github/workflows/reusable-release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ jobs:
364364
TARBALL_EXT: "zip"
365365
DISTRO: na
366366
CABAL_DIR: "C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
367-
GHCUP_INSTALL_BASE_PREFIX: "/c"
368367
strategy:
369368
fail-fast: false
370369
matrix:

Cabal/src/Distribution/Compat/Internal/TempFile.hs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ module Distribution.Compat.Internal.TempFile
1010

1111
import Distribution.Compat.Exception
1212

13+
import GHC.IORef (IORef, atomicModifyIORef'_, newIORef)
1314
import System.FilePath ((</>))
14-
1515
import System.IO (Handle, openBinaryTempFile, openBinaryTempFileWithDefaultPermissions, openTempFile)
1616
import System.IO.Error (isAlreadyExistsError)
17+
import System.IO.Unsafe (unsafePerformIO)
1718
import System.Posix.Internals (c_getpid)
1819

1920
#if defined(mingw32_HOST_OS) || defined(ghcjs_HOST_OS)
@@ -28,17 +29,21 @@ openNewBinaryFile = openBinaryTempFileWithDefaultPermissions
2829
createTempDirectory :: FilePath -> String -> IO FilePath
2930
createTempDirectory dir template = do
3031
pid <- c_getpid
31-
findTempName pid
32-
where
33-
findTempName x = do
34-
let relpath = template ++ "-" ++ show x
35-
dirpath = dir </> relpath
36-
r <- tryIO $ mkPrivateDir dirpath
37-
case r of
38-
Right _ -> return relpath
39-
Left e
40-
| isAlreadyExistsError e -> findTempName (x + 1)
41-
| otherwise -> ioError e
32+
let findTempName = do
33+
(counter, _) <- atomicModifyIORef'_ tempDirectoryCounter (+ 1)
34+
let relpath = template ++ "-" ++ show pid ++ show counter
35+
dirpath = dir </> relpath
36+
r <- tryIO $ mkPrivateDir dirpath
37+
case r of
38+
Right _ -> pure relpath
39+
Left e
40+
| isAlreadyExistsError e -> findTempName
41+
| otherwise -> ioError e
42+
findTempName
43+
44+
tempDirectoryCounter :: IORef Word
45+
tempDirectoryCounter = unsafePerformIO $ newIORef 0
46+
{-# NOINLINE tempDirectoryCounter #-}
4247

4348
mkPrivateDir :: String -> IO ()
4449
#if defined(mingw32_HOST_OS) || defined(ghcjs_HOST_OS)

changelog.d/pr-11872.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
synopsis: Improve name assigning for temporary folders
3+
packages: [Cabal,cabal-install]
4+
prs: 11872
5+
---
6+
7+
Now `createTempDirectory` from `Distribution.Compat.Internal.TempFile` uses a global counter as a part of temporary folder name template, so that probing is less likely to fail. The change should be invisible for users.

0 commit comments

Comments
 (0)