Skip to content

Commit a27014a

Browse files
committed
fixup
1 parent e83ac60 commit a27014a

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
@@ -45,7 +45,12 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: View {
4545
loading = true
4646
defer { loading = false }
4747
do throws(DaemonError) {
48+
// TODO: Support selecting & deleting multiple sessions at once
4849
try await fileSync.deleteSessions(ids: [selection!])
50+
if fileSync.sessionState.isEmpty {
51+
// Last session was deleted, stop the daemon
52+
await fileSync.stop()
53+
}
4954
} catch {
5055
deleteError = error
5156
}
@@ -60,7 +65,7 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: View {
6065
Divider()
6166
Button {
6267
Task {
63-
// TODO: Support pausing & resuming multiple selections
68+
// TODO: Support pausing & resuming multiple sessions at once
6469
switch selectedSession.status {
6570
case .paused:
6671
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