Skip to content

Commit 0025e9c

Browse files
imsodinAudriusButkevicius
authored andcommitted
all: Refactor cmd/syncthing creating lib/syncthing (ref syncthing#4085) (syncthing#5805)
* add skeleton for lib/syncthing * copy syncthingMain to lib/syncthing (verbatim) * Remove code to deduplicate copies of syncthingMain * fix simple build errors * move stuff from main to syncthing with minimal mod * merge runtime options * actually use syncthing.App * pass io.writer to lib/syncthing for auditing * get rid of env stuff in lib/syncthing * add .Error() and comments * review: Remove fs interactions from lib * and go 1.13 happened * utility functions
1 parent 82b70b9 commit 0025e9c

13 files changed

+584
-398
lines changed

cmd/syncthing/main.go

Lines changed: 56 additions & 388 deletions
Large diffs are not rendered by default.

cmd/syncthing/auditservice.go renamed to lib/syncthing/auditservice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
55
// You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
package main
7+
package syncthing
88

99
import (
1010
"encoding/json"

cmd/syncthing/auditservice_test.go renamed to lib/syncthing/auditservice_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
55
// You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
package main
7+
package syncthing
88

99
import (
1010
"bytes"

cmd/syncthing/cpuusage.go renamed to lib/syncthing/cpuusage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
55
// You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
package main
7+
package syncthing
88

99
import (
1010
"math"

cmd/syncthing/cpuusage_solaris.go renamed to lib/syncthing/cpuusage_solaris.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
//+build solaris
88

9-
package main
9+
package syncthing
1010

1111
import (
1212
"encoding/binary"

cmd/syncthing/cpuusage_unix.go renamed to lib/syncthing/cpuusage_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
//+build !windows,!solaris
88

9-
package main
9+
package syncthing
1010

1111
import "syscall"
1212
import "time"

cmd/syncthing/cpuusage_windows.go renamed to lib/syncthing/cpuusage_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
//+build windows
88

9-
package main
9+
package syncthing
1010

1111
import "syscall"
1212
import "time"

lib/syncthing/debug.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (C) 2014 The Syncthing Authors.
2+
//
3+
// This Source Code Form is subject to the terms of the Mozilla Public
4+
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
5+
// You can obtain one at https://mozilla.org/MPL/2.0/.
6+
7+
package syncthing
8+
9+
import (
10+
"os"
11+
"strings"
12+
13+
"github.com/syncthing/syncthing/lib/logger"
14+
)
15+
16+
var (
17+
l = logger.DefaultLogger.NewFacility("app", "Main run facility")
18+
)
19+
20+
func init() {
21+
l.SetDebug("app", strings.Contains(os.Getenv("STTRACE"), "app") || os.Getenv("STTRACE") == "all")
22+
}

cmd/syncthing/superuser_unix.go renamed to lib/syncthing/superuser_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// +build !windows
88

9-
package main
9+
package syncthing
1010

1111
import (
1212
"os"

cmd/syncthing/superuser_windows.go renamed to lib/syncthing/superuser_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
55
// You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
package main
7+
package syncthing
88

99
import "syscall"
1010

0 commit comments

Comments
 (0)