Skip to content

Commit ee18126

Browse files
authored
Merge pull request #6075 from unisonweb/arya/tweak-cache-key
2 parents d9a5ddb + d2ed60f commit ee18126

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

parser-typechecker/src/Unison/Codebase/Init.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ data SpecifiedCodebase
4949
data CodebaseLockOption
5050
= DoLock
5151
| DontLock
52+
| BlockUntilLock
53+
deriving stock (Show)
5254

5355
data BackupStrategy
5456
= -- Create a backup of the codebase in the same directory as the codebase,

parser-typechecker/src/Unison/Codebase/SqliteCodebase.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Data.Either.Extra ()
1414
import Data.Foldable qualified as Foldable
1515
import Data.Map qualified as Map
1616
import Data.Set qualified as Set
17-
import System.FileLock (SharedExclusive (Exclusive), withTryFileLock)
17+
import System.FileLock (SharedExclusive (Exclusive), withFileLock, withTryFileLock)
1818
import U.Codebase.HashTags (BranchHash, CausalHash)
1919
import U.Codebase.Sqlite.Operations qualified as Operations
2020
import Unison.Codebase (Codebase, CodebasePath)
@@ -322,6 +322,12 @@ sqliteCodebase debugName root localOrRemote lockOption migrationStrategy action
322322
withTryFileLock (lockfilePath root) Exclusive (\_flock -> runInIO ma) <&> \case
323323
Nothing -> Left OpenCodebaseFileLockFailed
324324
Just x -> x
325+
BlockUntilLock -> withRunInIO \runInIO ->
326+
withTryFileLock (lockfilePath root) Exclusive (\_flock -> runInIO ma) >>= \case
327+
Nothing -> do
328+
liftIO (putStrLn "Waiting for codebase lock...")
329+
withFileLock (lockfilePath root) Exclusive (\_flock -> runInIO ma)
330+
Just x -> pure x
325331

326332
ensureMigrated ::
327333
(MonadUnliftIO m) =>

unison-cli/src/Unison/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ runTranscripts' version progName transcriptDir markdownFiles = do
515515
and
516516
<$> getCodebaseOrExit
517517
(Just (DontCreateCodebaseWhenMissing transcriptDir))
518-
SC.DoLock
518+
SC.BlockUntilLock
519519
(SC.MigrateAutomatically SC.Backup SC.Vacuum)
520520
\(_, codebasePath, theCodebase) -> do
521521
let isTest = False

0 commit comments

Comments
 (0)