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

Commitffa6e5f

Browse files
committed
review
1 parent35e8cc3 commitffa6e5f

File tree

4 files changed

+42
-49
lines changed

4 files changed

+42
-49
lines changed

‎Coder Desktop/VPNLib/FileSync/FileSyncDaemon.swift

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import os
66
@MainActor
77
publicprotocolFileSyncDaemon:ObservableObject{
88
varstate:DaemonState{get}
9-
func start()asyncthrows
10-
func stop()asyncthrows
9+
func start()asyncthrows(DaemonError)
10+
func stop()asyncthrows(DaemonError)
1111
}
1212

1313
@MainActor
@@ -47,7 +47,7 @@ public class MutagenDaemon: FileSyncDaemon {
4747
}
4848
}
4949

50-
publicfunc start()asyncthrows{
50+
publicfunc start()asyncthrows(DaemonError){
5151
if case.unavailable= state{return}
5252

5353
// Stop an orphaned daemon, if there is one
@@ -59,16 +59,21 @@ public class MutagenDaemon: FileSyncDaemon {
5959
try mutagenProcess?.run()
6060
}catch{
6161
state=.failed("Failed to start file sync daemon:\(error)")
62-
throwMutagenDaemonError.daemonStartFailure(error)
62+
throwDaemonError.daemonStartFailure(error)
6363
}
6464

65-
tryawaitconnect()
65+
do{
66+
tryawaitconnect()
67+
}catch{
68+
state=.failed("failed to connect to file sync daemon:\(error)")
69+
throwDaemonError.daemonStartFailure(error)
70+
}
6671

6772
state=.running
68-
logger.info("mutagen daemon started")
73+
logger.info("mutagen daemon started, pid:\(self.mutagenProcess?.processIdentifier.description??"unknown")")
6974
}
7075

71-
privatefunc connect()asyncthrows{
76+
privatefunc connect()asyncthrows(DaemonError){
7277
guard client==nilelse{
7378
// Already connected
7479
return
@@ -86,8 +91,8 @@ public class MutagenDaemon: FileSyncDaemon {
8691
)
8792
}catch{
8893
logger.error("Failed to connect to gRPC:\(error)")
89-
tryawaitcleanupGRPC()
90-
throwMutagenDaemonError.connectionFailure(error)
94+
try?awaitcleanupGRPC()
95+
throwDaemonError.connectionFailure(error)
9196
}
9297
}
9398

@@ -100,7 +105,7 @@ public class MutagenDaemon: FileSyncDaemon {
100105
group=nil
101106
}
102107

103-
publicfunc stop()asyncthrows{
108+
publicfunc stop()asyncthrows(DaemonError){
104109
if case.unavailable= state{return}
105110
state=.stopped
106111
guardFileManager.default.fileExists(atPath: mutagenDaemonSocket.path)else{
@@ -169,7 +174,7 @@ public enum DaemonState {
169174
case unavailable
170175
}
171176

172-
publicenumMutagenDaemonError:Error{
177+
publicenumDaemonError:Error{
173178
case daemonStartFailure(Error)
174179
case connectionFailure(Error)
175180
}

‎Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ APP_SIGNING_KEYCHAIN := $(if $(wildcard $(KEYCHAIN_FILE)),$(shell realpath $(KEY
3333
.PHONY: setup
3434
setup:\
3535
$(XCPROJECT)\
36-
proto
36+
$(PROJECT)/VPNLib/vpn.proto\
37+
$(PROJECT)/VPNLib/FileSync/daemon.proto
3738

3839
$(XCPROJECT):$(PROJECT)/project.yml
3940
cd$(PROJECT);\

‎flake.lock

Lines changed: 14 additions & 35 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎flake.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
inputs={
55
nixpkgs.url="github:nixos/nixpkgs/nixos-unstable";
66
flake-utils.url="github:numtide/flake-utils";
7-
grpc-swift.url="github:i10416/grpc-swift-flake";
7+
flake-parts={
8+
url="github:hercules-ci/flake-parts";
9+
inputs.nixpkgs-lib.follows="nixpkgs";
10+
};
11+
grpc-swift={
12+
url="github:i10416/grpc-swift-flake";
13+
inputs.nixpkgs.follows="nixpkgs";
14+
inputs.flake-parts.follows="flake-parts";
15+
};
816
};
917

1018
outputs=
1119
{
12-
self,
1320
nixpkgs,
1421
flake-utils,
1522
grpc-swift,
23+
...
1624
}:
1725
flake-utils.lib.eachSystem
1826
(withflake-utils.lib.system;[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp