Skip to content

Commit c6dc4ff

Browse files
committed
Fix lock not being released.
1 parent 6167021 commit c6dc4ff

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

integration-tests/src/Main.gren

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ update msg model =
137137
Lock.LockReleased { path, model = lockModel, command } ->
138138
{ model = { model | locks = lockModel }
139139
, command =
140-
log "Lock Released" model.stdout
140+
Cmd.batch
141+
[ log "Lock Released" model.stdout
142+
, Cmd.map LockMsg command
143+
]
141144
}
142145

143146
Lock.AlreadyLocked path ->

integration-tests/test/commands.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ describe("compiler-node", () => {
6767
.cwd(rootDir)
6868
.fork("bin/app", ["lock", "10"], {})
6969
.stdout("Lock Aquired")
70-
.stdout("Lock Released");
70+
.stdout("Lock Released")
71+
.expect(({ assert }) => {
72+
assert.equal(false, fs.existsSync(".lock"))
73+
});
7174
});
7275
});
7376
});

src/FileSystem/Lock.gren

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ update fsPerm msg model =
133133
{ path = path
134134
, model = Dict.remove (Path.toPosixString lockPath) model
135135
, command =
136-
FileSystem.remove fsPerm { recursive = False, ignoreErrors = False } lockPath
137-
|> Task.onError (\_ -> Task.succeed lockPath)
136+
FileSystem.remove fsPerm { recursive = True, ignoreErrors = False } lockPath
137+
|> Task.onError (\err -> Task.succeed lockPath)
138138
|> Task.execute
139139
}
140140

@@ -149,7 +149,7 @@ update fsPerm msg model =
149149
LockMetaCheck { path, result = Ok { time, meta } } ->
150150
if Time.posixToMillis time - Time.posixToMillis meta.lastAccessed > 5000 then
151151
-- Lock is stale, let's try again
152-
FileSystem.remove fsPerm { recursive = False, ignoreErrors = False } path
152+
FileSystem.remove fsPerm { recursive = True, ignoreErrors = False } path
153153
|> Task.onError (\_ -> Task.succeed path)
154154
|> Task.perform (\_ -> Lock (fromLockPath path))
155155
|> Working

0 commit comments

Comments
 (0)