Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb6cbca

Browse files
committed
pausing & unpausing
1 parent1798317 commitcb6cbca

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

‎Coder-Desktop/Coder-Desktop/Preview Content/PreviewFileSync.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ final class PreviewFileSync: FileSyncDaemon {
2121
func createSession(localPath _:String, agentHost _:String, remotePath _:String)asyncthrows(DaemonError){}
2222

2323
func deleteSessions(ids _:[String])asyncthrows(VPNLib.DaemonError){}
24+
25+
func pauseSessions(ids _:[String])asyncthrows(VPNLib.DaemonError){}
26+
27+
func resumeSessions(ids _:[String])asyncthrows(VPNLib.DaemonError){}
2428
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: View {
6565
iflet selectedSession= fileSync.sessionState.first(where:{ $0.id== selection}){
6666
Divider()
6767
Button{
68-
// TODO: Pause & Unpause
68+
Task{
69+
// TODO: Support pausing & resuming multiple selections
70+
switch selectedSession.status{
71+
case.paused:
72+
tryawait fileSync.resumeSessions(ids:[selectedSession.id])
73+
default:
74+
tryawait fileSync.pauseSessions(ids:[selectedSession.id])
75+
}
76+
}
6977
} label:{
7078
switch selectedSession.status{
7179
case.paused:

‎Coder-Desktop/VPNLib/FileSync/FileSyncDaemon.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public protocol FileSyncDaemon: ObservableObject {
1515
func refreshSessions()async
1616
func createSession(localPath:String, agentHost:String, remotePath:String)asyncthrows(DaemonError)
1717
func deleteSessions(ids:[String])asyncthrows(DaemonError)
18+
func pauseSessions(ids:[String])asyncthrows(DaemonError)
19+
func resumeSessions(ids:[String])asyncthrows(DaemonError)
1820
}
1921

2022
@MainActor

‎Coder-Desktop/VPNLib/FileSync/FileSyncManagement.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,38 @@ public extension MutagenDaemon {
7777
}
7878
awaitrefreshSessions()
7979
}
80+
81+
func pauseSessions(ids:[String])asyncthrows(DaemonError){
82+
let(stream, promptID)=tryawaithost()
83+
defer{ stream.cancel()}
84+
guard case.running= stateelse{return}
85+
do{
86+
_=tryawait client!.sync.pause(Synchronization_PauseRequest.with{ reqin
87+
req.prompter= promptID
88+
req.selection=.with{ selectionin
89+
selection.specifications= ids
90+
}
91+
})
92+
}catch{
93+
throw.grpcFailure(error)
94+
}
95+
awaitrefreshSessions()
96+
}
97+
98+
func resumeSessions(ids:[String])asyncthrows(DaemonError){
99+
let(stream, promptID)=tryawaithost()
100+
defer{ stream.cancel()}
101+
guard case.running= stateelse{return}
102+
do{
103+
_=tryawait client!.sync.resume(Synchronization_ResumeRequest.with{ reqin
104+
req.prompter= promptID
105+
req.selection=.with{ selectionin
106+
selection.specifications= ids
107+
}
108+
})
109+
}catch{
110+
throw.grpcFailure(error)
111+
}
112+
awaitrefreshSessions()
113+
}
80114
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp