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

Commit5ca8a83

Browse files
committed
fmt & lint
1 parent37b5708 commit5ca8a83

File tree

3 files changed

+54
-56
lines changed

3 files changed

+54
-56
lines changed

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

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public class MutagenDaemon: FileSyncDaemon {
3838
privateletmutagenDaemonSocket:URL
3939

4040
// Non-nil when the daemon is running
41+
varclient:DaemonClient?
4142
privatevargroup:MultiThreadedEventLoopGroup?
4243
privatevarchannel:GRPCChannel?
43-
privatevarclient:DaemonClient?
4444

4545
// Protect start & stop transitions against re-entrancy
4646
privatelettransition=AsyncSemaphore(value:1)
@@ -293,59 +293,6 @@ public class MutagenDaemon: FileSyncDaemon {
293293
}
294294
}
295295

296-
297-
extensionMutagenDaemon{
298-
typealiasPromptStream=GRPCAsyncBidirectionalStreamingCall<Prompting_HostRequest,Prompting_HostResponse>
299-
300-
func Host(allowPrompts:Bool=true)asyncthrows(DaemonError)->(PromptStream, identifier:String){
301-
letstream= client!.prompt.makeHostCall()
302-
303-
do{
304-
tryawait stream.requestStream.send(.with{ reqin req.allowPrompts= allowPrompts})
305-
}catch{
306-
throw.grpcFailure(error)
307-
}
308-
309-
// We can't make call `makeAsyncIterator` more than once
310-
// (as a for-loop would do implicitly)
311-
variter= stream.responseStream.makeAsyncIterator()
312-
313-
// "Receive the initialization response, validate it, and extract the prompt identifier"
314-
letinitResp:Prompting_HostResponse?
315-
do{
316-
initResp=tryawait iter.next()
317-
}catch{
318-
throw.grpcFailure(error)
319-
}
320-
guardlet initResp= initRespelse{
321-
throw.unexpectedStreamClosure
322-
}
323-
// TODO: we'll always accept prompts for now
324-
try initResp.ensureValid(first:true, allowPrompts: allowPrompts)
325-
326-
Task.detached(priority:.background){
327-
do{
328-
whilelet resp=tryawait iter.next(){
329-
debugPrint(resp)
330-
try resp.ensureValid(first:false, allowPrompts: allowPrompts)
331-
switch resp.isPrompt{
332-
casetrue:
333-
// TODO: Handle prompt
334-
break
335-
casefalse:
336-
// TODO: Handle message
337-
break
338-
}
339-
}
340-
}catch{
341-
// TODO: Log prompter stream error
342-
}
343-
}
344-
return(stream, identifier: initResp.identifier)
345-
}
346-
}
347-
348-
349296
structDaemonClient{
350297
letmgmt:Daemon_DaemonAsyncClient
351298
letsync:Synchronization_SynchronizationAsyncClient
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import GRPC
2+
3+
extensionMutagenDaemon{
4+
typealiasPromptStream=GRPCAsyncBidirectionalStreamingCall<Prompting_HostRequest,Prompting_HostResponse>
5+
6+
func host(allowPrompts:Bool=true)asyncthrows(DaemonError)->(PromptStream, identifier:String){
7+
letstream= client!.prompt.makeHostCall()
8+
9+
do{
10+
tryawait stream.requestStream.send(.with{ reqin req.allowPrompts= allowPrompts})
11+
}catch{
12+
throw.grpcFailure(error)
13+
}
14+
15+
// We can't make call `makeAsyncIterator` more than once
16+
// (as a for-loop would do implicitly)
17+
variter= stream.responseStream.makeAsyncIterator()
18+
19+
// "Receive the initialization response, validate it, and extract the prompt identifier"
20+
letinitResp:Prompting_HostResponse?
21+
do{
22+
initResp=tryawait iter.next()
23+
}catch{
24+
throw.grpcFailure(error)
25+
}
26+
guardlet initRespelse{
27+
throw.unexpectedStreamClosure
28+
}
29+
// TODO: we'll always accept prompts for now
30+
try initResp.ensureValid(first:true, allowPrompts: allowPrompts)
31+
32+
Task.detached(priority:.background){
33+
do{
34+
whilelet resp=tryawait iter.next(){
35+
debugPrint(resp)
36+
try resp.ensureValid(first:false, allowPrompts: allowPrompts)
37+
switch resp.isPrompt{
38+
casetrue:
39+
// TODO: Handle prompt
40+
break
41+
casefalse:
42+
// TODO: Handle message
43+
break
44+
}
45+
}
46+
}catch{
47+
// TODO: Log prompter stream error
48+
}
49+
}
50+
return(stream, identifier: initResp.identifier)
51+
}
52+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func humanReadableBytes(_ bytes: UInt64) -> String {
5858
ByteCountFormatter().string(fromByteCount:Int64(bytes))
5959
}
6060

61-
6261
extensionPrompting_HostResponse{
6362
func ensureValid(first:Bool, allowPrompts:Bool)throws(DaemonError){
6463
if first{
@@ -80,4 +79,4 @@ extension Prompting_HostResponse {
8079
}
8180
}
8281
}
83-
}
82+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp