File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed
parser-typechecker/src/Unison/Codebase Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ data SpecifiedCodebase
4949data CodebaseLockOption
5050 = DoLock
5151 | DontLock
52+ | BlockUntilLock
53+ deriving stock (Show )
5254
5355data BackupStrategy
5456 = -- Create a backup of the codebase in the same directory as the codebase,
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import Data.Either.Extra ()
1414import Data.Foldable qualified as Foldable
1515import Data.Map qualified as Map
1616import Data.Set qualified as Set
17- import System.FileLock (SharedExclusive (Exclusive ), withTryFileLock )
17+ import System.FileLock (SharedExclusive (Exclusive ), withFileLock , withTryFileLock )
1818import U.Codebase.HashTags (BranchHash , CausalHash )
1919import U.Codebase.Sqlite.Operations qualified as Operations
2020import 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
326332ensureMigrated ::
327333 (MonadUnliftIO m ) =>
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments