Skip to content

Commit 126e84f

Browse files
committed
fixup
1 parent 42096fd commit 126e84f

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncConfig.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: View {
5151
loading = true
5252
defer { loading = false }
5353
do throws(DaemonError) {
54+
// TODO: Support selecting & deleting multiple sessions at once
5455
try await fileSync.deleteSessions(ids: [selection!])
56+
if fileSync.sessionState.isEmpty {
57+
// Last session was deleted, stop the daemon
58+
await fileSync.stop()
59+
}
5560
} catch {
5661
deleteError = error
5762
}
@@ -66,7 +71,7 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: View {
6671
Divider()
6772
Button {
6873
Task {
69-
// TODO: Support pausing & resuming multiple selections
74+
// TODO: Support pausing & resuming multiple sessions at once
7075
switch selectedSession.status {
7176
case .paused:
7277
try await fileSync.resumeSessions(ids: [selectedSession.id])

Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncSessionModal.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
8686
defer { loading = false }
8787
do throws(DaemonError) {
8888
if let existingSession {
89-
// TODO: Support selecting & deleting multiple sessions at once
9089
try await fileSync.deleteSessions(ids: [existingSession.id])
9190
}
9291
try await fileSync.createSession(

Coder-Desktop/Coder-DesktopTests/Util.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class MockFileSyncDaemon: FileSyncDaemon {
4848
}
4949

5050
func createSession(localPath _: String, agentHost _: String, remotePath _: String) async throws(DaemonError) {}
51+
52+
func pauseSessions(ids _: [String]) async throws(VPNLib.DaemonError) {}
53+
54+
func resumeSessions(ids _: [String]) async throws(VPNLib.DaemonError) {}
5155
}
5256

5357
extension Inspection: @unchecked Sendable, @retroactive InspectionEmissary {}

Coder-Desktop/VPNLib/FileSync/FileSyncDaemon.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public class MutagenDaemon: FileSyncDaemon {
7777
return
7878
}
7979
await refreshSessions()
80+
if sessionState.isEmpty {
81+
logger.info("No sync sessions found on startup, stopping daemon")
82+
await stop()
83+
}
8084
}
8185
}
8286

Coder-Desktop/VPNLib/FileSync/FileSyncManagement.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ public extension MutagenDaemon {
1313
return
1414
}
1515
sessionState = sessions.sessionStates.map { FileSyncSession(state: $0) }
16-
if sessionState.isEmpty {
17-
logger.info("No sync sessions found")
18-
await stop()
19-
}
2016
}
2117

2218
func createSession(
@@ -61,7 +57,8 @@ public extension MutagenDaemon {
6157
}
6258

6359
func deleteSessions(ids: [String]) async throws(DaemonError) {
64-
// Terminating sessions does not require prompting
60+
// Terminating sessions does not require prompting, according to the
61+
// Mutagen CLI
6562
let (stream, promptID) = try await host(allowPrompts: false)
6663
defer { stream.cancel() }
6764
guard case .running = state else { return }
@@ -79,7 +76,9 @@ public extension MutagenDaemon {
7976
}
8077

8178
func pauseSessions(ids: [String]) async throws(DaemonError) {
82-
let (stream, promptID) = try await host()
79+
// Pausing sessions does not require prompting, according to the
80+
// Mutagen CLI
81+
let (stream, promptID) = try await host(allowPrompts: false)
8382
defer { stream.cancel() }
8483
guard case .running = state else { return }
8584
do {
@@ -96,7 +95,9 @@ public extension MutagenDaemon {
9695
}
9796

9897
func resumeSessions(ids: [String]) async throws(DaemonError) {
99-
let (stream, promptID) = try await host()
98+
// Resuming sessions does not require prompting, according to the
99+
// Mutagen CLI
100+
let (stream, promptID) = try await host(allowPrompts: false)
100101
defer { stream.cancel() }
101102
guard case .running = state else { return }
102103
do {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy