Compare commits
9
Commits
058bcd7334
...
v0.9.19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ce8261d89 | ||
|
|
25c080b46f | ||
|
|
ee765990b7 | ||
|
|
77fcb52b6a | ||
|
|
aaec3330a9 | ||
|
|
3f55a885a1 | ||
|
|
80a1c931a9 | ||
|
|
a147f4bb77 | ||
|
|
e4316aec6e |
@@ -67,28 +67,22 @@ func main() {
|
|||||||
|
|
||||||
checkRequiredGoVersion()
|
checkRequiredGoVersion()
|
||||||
|
|
||||||
if check() != nil {
|
|
||||||
setup()
|
|
||||||
}
|
|
||||||
|
|
||||||
if flag.NArg() == 0 {
|
if flag.NArg() == 0 {
|
||||||
install("./cmd/...")
|
install("./cmd/...")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch flag.Arg(0) {
|
for _, cmd := range flag.Args() {
|
||||||
|
switch cmd {
|
||||||
|
case "setup":
|
||||||
|
setup()
|
||||||
|
|
||||||
case "install":
|
case "install":
|
||||||
pkg := "./cmd/..."
|
pkg := "./cmd/..."
|
||||||
if flag.NArg() > 2 {
|
|
||||||
pkg = flag.Arg(1)
|
|
||||||
}
|
|
||||||
install(pkg)
|
install(pkg)
|
||||||
|
|
||||||
case "build":
|
case "build":
|
||||||
pkg := "./cmd/syncthing"
|
pkg := "./cmd/syncthing"
|
||||||
if flag.NArg() > 2 {
|
|
||||||
pkg = flag.Arg(1)
|
|
||||||
}
|
|
||||||
var tags []string
|
var tags []string
|
||||||
if noupgrade {
|
if noupgrade {
|
||||||
tags = []string{"noupgrade"}
|
tags = []string{"noupgrade"}
|
||||||
@@ -97,9 +91,6 @@ func main() {
|
|||||||
|
|
||||||
case "test":
|
case "test":
|
||||||
pkg := "./..."
|
pkg := "./..."
|
||||||
if flag.NArg() > 2 {
|
|
||||||
pkg = flag.Arg(1)
|
|
||||||
}
|
|
||||||
test(pkg)
|
test(pkg)
|
||||||
|
|
||||||
case "assets":
|
case "assets":
|
||||||
@@ -127,13 +118,9 @@ func main() {
|
|||||||
clean()
|
clean()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Fatalf("Unknown command %q", flag.Arg(0))
|
log.Fatalf("Unknown command %q", cmd)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func check() error {
|
|
||||||
_, err := exec.LookPath("godep")
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkRequiredGoVersion() {
|
func checkRequiredGoVersion() {
|
||||||
@@ -163,24 +150,25 @@ func setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func test(pkg string) {
|
func test(pkg string) {
|
||||||
runPrint("godep", "go", "test", "-short", "-timeout", "10s", pkg)
|
setBuildEnv()
|
||||||
|
runPrint("go", "test", "-short", "-timeout", "10s", pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func install(pkg string) {
|
func install(pkg string) {
|
||||||
os.Setenv("GOBIN", "./bin")
|
os.Setenv("GOBIN", "./bin")
|
||||||
setBuildEnv()
|
setBuildEnv()
|
||||||
runPrint("godep", "go", "install", "-ldflags", ldflags(), pkg)
|
runPrint("go", "install", "-ldflags", ldflags(), pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(pkg string, tags []string) {
|
func build(pkg string, tags []string) {
|
||||||
rmr("syncthing", "syncthing.exe")
|
rmr("syncthing", "syncthing.exe")
|
||||||
args := []string{"go", "build", "-ldflags", ldflags()}
|
args := []string{"build", "-ldflags", ldflags()}
|
||||||
if len(tags) > 0 {
|
if len(tags) > 0 {
|
||||||
args = append(args, "-tags", strings.Join(tags, ","))
|
args = append(args, "-tags", strings.Join(tags, ","))
|
||||||
}
|
}
|
||||||
args = append(args, pkg)
|
args = append(args, pkg)
|
||||||
setBuildEnv()
|
setBuildEnv()
|
||||||
runPrint("godep", args...)
|
runPrint("go", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildTar() {
|
func buildTar() {
|
||||||
@@ -230,10 +218,18 @@ func setBuildEnv() {
|
|||||||
if goarch == "386" {
|
if goarch == "386" {
|
||||||
os.Setenv("GO386", "387")
|
os.Setenv("GO386", "387")
|
||||||
}
|
}
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Warning: can't determine current dir:", err)
|
||||||
|
log.Println("Build might not work as expected")
|
||||||
|
}
|
||||||
|
os.Setenv("GOPATH", fmt.Sprintf("%s%c%s", filepath.Join(wd, "Godeps", "_workspace"), os.PathListSeparator, os.Getenv("GOPATH")))
|
||||||
|
log.Println("GOPATH=" + os.Getenv("GOPATH"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func assets() {
|
func assets() {
|
||||||
runPipe("internal/auto/gui.files.go", "godep", "go", "run", "cmd/genassets/main.go", "gui")
|
setBuildEnv()
|
||||||
|
runPipe("internal/auto/gui.files.go", "go", "run", "cmd/genassets/main.go", "gui")
|
||||||
}
|
}
|
||||||
|
|
||||||
func xdr() {
|
func xdr() {
|
||||||
|
|||||||
@@ -620,6 +620,10 @@ nextRepo:
|
|||||||
go standbyMonitor()
|
go standbyMonitor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.Options.AutoUpgradeIntervalH > 0 {
|
||||||
|
go autoUpgrade()
|
||||||
|
}
|
||||||
|
|
||||||
events.Default.Log(events.StartupComplete, nil)
|
events.Default.Log(events.StartupComplete, nil)
|
||||||
go generateEvents()
|
go generateEvents()
|
||||||
|
|
||||||
@@ -1172,3 +1176,36 @@ func standbyMonitor() {
|
|||||||
now = time.Now()
|
now = time.Now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func autoUpgrade() {
|
||||||
|
var skipped bool
|
||||||
|
interval := time.Duration(cfg.Options.AutoUpgradeIntervalH) * time.Hour
|
||||||
|
for {
|
||||||
|
if skipped {
|
||||||
|
time.Sleep(interval)
|
||||||
|
} else {
|
||||||
|
skipped = true
|
||||||
|
}
|
||||||
|
|
||||||
|
rel, err := upgrade.LatestRelease(strings.Contains(Version, "-beta"))
|
||||||
|
if err != nil {
|
||||||
|
l.Warnln("Automatic upgrade:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if upgrade.CompareVersions(rel.Tag, Version) <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
l.Infof("Automatic upgrade (current %q < latest %q)", Version, rel.Tag)
|
||||||
|
err = upgrade.UpgradeTo(rel, GoArchExtra)
|
||||||
|
if err != nil {
|
||||||
|
l.Warnln("Automatic upgrade:", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
l.Warnf("Automatically upgraded to version %q. Restarting in 1 minute.", rel.Tag)
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
stop <- exitUpgrading
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -533,6 +533,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
|||||||
$scope.tmpOptions = angular.copy($scope.config.Options);
|
$scope.tmpOptions = angular.copy($scope.config.Options);
|
||||||
$scope.tmpOptions.UREnabled = ($scope.tmpOptions.URAccepted > 0);
|
$scope.tmpOptions.UREnabled = ($scope.tmpOptions.URAccepted > 0);
|
||||||
$scope.tmpOptions.NodeName = $scope.thisNode().Name;
|
$scope.tmpOptions.NodeName = $scope.thisNode().Name;
|
||||||
|
$scope.tmpOptions.AutoUpgradeEnabled = ($scope.tmpOptions.AutoUpgradeIntervalH > 0);
|
||||||
$scope.tmpGUI = angular.copy($scope.config.GUI);
|
$scope.tmpGUI = angular.copy($scope.config.GUI);
|
||||||
$('#settings').modal();
|
$('#settings').modal();
|
||||||
};
|
};
|
||||||
@@ -563,6 +564,13 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
|
|||||||
$scope.tmpOptions.URAccepted = -1;
|
$scope.tmpOptions.URAccepted = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if auto-upgrade has been enabled or disabled
|
||||||
|
if ($scope.tmpOptions.AutoUpgradeEnabled) {
|
||||||
|
$scope.tmpOptions.AutoUpgradeIntervalH = $scope.tmpOptions.AutoUpgradeIntervalH || 12;
|
||||||
|
} else {
|
||||||
|
$scope.tmpOptions.AutoUpgradeIntervalH = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if protocol will need to be changed on restart
|
// Check if protocol will need to be changed on restart
|
||||||
if ($scope.config.GUI.UseTLS !== $scope.tmpGUI.UseTLS) {
|
if ($scope.config.GUI.UseTLS !== $scope.tmpGUI.UseTLS) {
|
||||||
$scope.protocolChanged = true;
|
$scope.protocolChanged = true;
|
||||||
|
|||||||
+24
-14
@@ -383,13 +383,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label translate for="name">Node Name</label>
|
<label translate for="name">Node Name</label>
|
||||||
<input placeholder="Home Server" id="name" class="form-control" type="text" ng-model="currentNode.Name"></input>
|
<input id="name" class="form-control" type="text" ng-model="currentNode.Name"></input>
|
||||||
<p translate ng-if="currentNode.NodeID == myID" class="help-block">Shown instead of Node ID in the cluster status. Will be advertised to other nodes as an optional default name.</p>
|
<p translate ng-if="currentNode.NodeID == myID" class="help-block">Shown instead of Node ID in the cluster status. Will be advertised to other nodes as an optional default name.</p>
|
||||||
<p translate ng-if="currentNode.NodeID != myID" class="help-block">Shown instead of Node ID in the cluster status. Will be updated to the name the node advertises if left empty.</p>
|
<p translate ng-if="currentNode.NodeID != myID" class="help-block">Shown instead of Node ID in the cluster status. Will be updated to the name the node advertises if left empty.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label translate for="addresses">Addresses</label>
|
<label translate for="addresses">Addresses</label>
|
||||||
<input placeholder="dynamic" ng-disabled="currentNode.NodeID == myID" id="addresses" class="form-control" type="text" ng-model="currentNode.AddressesStr"></input>
|
<input ng-disabled="currentNode.NodeID == myID" id="addresses" class="form-control" type="text" ng-model="currentNode.AddressesStr"></input>
|
||||||
<p translate class="help-block">Enter comma separated "ip:port" addresses or "dynamic" to perform automatic discovery of the address.</p>
|
<p translate class="help-block">Enter comma separated "ip:port" addresses or "dynamic" to perform automatic discovery of the address.</p>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="!editingSelf" class="form-group">
|
<div ng-if="!editingSelf" class="form-group">
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="form-group" ng-class="{'has-error': repoEditor.repoID.$invalid && repoEditor.repoID.$dirty}">
|
<div class="form-group" ng-class="{'has-error': repoEditor.repoID.$invalid && repoEditor.repoID.$dirty}">
|
||||||
<label for="repoID"><span translate>Repository ID</span></label>
|
<label for="repoID"><span translate>Repository ID</span></label>
|
||||||
<input name="repoID" placeholder="documents" ng-disabled="editingExisting" id="repoID" class="form-control" type="text" ng-model="currentRepo.ID" required unique-repo ng-pattern="/^[a-zA-Z0-9-_.]{1,64}$/"></input>
|
<input name="repoID" ng-disabled="editingExisting" id="repoID" class="form-control" type="text" ng-model="currentRepo.ID" required unique-repo ng-pattern="/^[a-zA-Z0-9-_.]{1,64}$/"></input>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
<span translate ng-if="repoEditor.repoID.$valid || repoEditor.repoID.$pristine">Short identifier for the repository. Must be the same on all cluster nodes.</span>
|
<span translate ng-if="repoEditor.repoID.$valid || repoEditor.repoID.$pristine">Short identifier for the repository. Must be the same on all cluster nodes.</span>
|
||||||
<span translate ng-if="repoEditor.repoID.$error.uniqueRepo">The repository ID must be unique.</span>
|
<span translate ng-if="repoEditor.repoID.$error.uniqueRepo">The repository ID must be unique.</span>
|
||||||
@@ -444,7 +444,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" ng-class="{'has-error': repoEditor.repoPath.$invalid && repoEditor.repoPath.$dirty}">
|
<div class="form-group" ng-class="{'has-error': repoEditor.repoPath.$invalid && repoEditor.repoPath.$dirty}">
|
||||||
<label translate for="repoPath">Repository Path</label>
|
<label translate for="repoPath">Repository Path</label>
|
||||||
<input name="repoPath" placeholder="~/Documents" ng-disabled="editingExisting" id="repoPath" class="form-control" type="text" ng-model="currentRepo.Directory" required></input>
|
<input name="repoPath" ng-disabled="editingExisting" id="repoPath" class="form-control" type="text" ng-model="currentRepo.Directory" required></input>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
<span translate ng-if="repoEditor.repoPath.$valid || repoEditor.repoPath.$pristine">Path to the repository on the local computer. Will be created if it does not exist. The tilde character (~) can be used as a shortcut for</span> <code>{{system.tilde}}</code>.
|
<span translate ng-if="repoEditor.repoPath.$valid || repoEditor.repoPath.$pristine">Path to the repository on the local computer. Will be created if it does not exist. The tilde character (~) can be used as a shortcut for</span> <code>{{system.tilde}}</code>.
|
||||||
<span translate ng-if="repoEditor.repoPath.$error.required && repoEditor.repoPath.$dirty">The repository path cannot be blank.</span>
|
<span translate ng-if="repoEditor.repoPath.$error.required && repoEditor.repoPath.$dirty">The repository path cannot be blank.</span>
|
||||||
@@ -452,7 +452,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" ng-class="{'has-error': repoEditor.rescanIntervalS.$invalid && repoEditor.rescanIntervalS.$dirty}">
|
<div class="form-group" ng-class="{'has-error': repoEditor.rescanIntervalS.$invalid && repoEditor.rescanIntervalS.$dirty}">
|
||||||
<label for="rescanIntervalS"><span translate>Rescan Interval</span> (s)</label>
|
<label for="rescanIntervalS"><span translate>Rescan Interval</span> (s)</label>
|
||||||
<input name="rescanIntervalS" placeholder="60" id="rescanIntervalS" class="form-control" type="number" ng-model="currentRepo.RescanIntervalS" required min="5"></input>
|
<input name="rescanIntervalS" id="rescanIntervalS" class="form-control" type="number" ng-model="currentRepo.RescanIntervalS" required min="5"></input>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
<span translate ng-if="!repoEditor.rescanIntervalS.$valid && repoEditor.rescanIntervalS.$dirty">The rescan interval must be at least 5 seconds.</span>
|
<span translate ng-if="!repoEditor.rescanIntervalS.$valid && repoEditor.rescanIntervalS.$dirty">The rescan interval must be at least 5 seconds.</span>
|
||||||
</p>
|
</p>
|
||||||
@@ -528,7 +528,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" ng-if="currentRepo.FileVersioningSelector == 'staggered'">
|
<div class="form-group" ng-if="currentRepo.FileVersioningSelector == 'staggered'">
|
||||||
<label translate for="staggeredVersionsPath">Versions Path</label>
|
<label translate for="staggeredVersionsPath">Versions Path</label>
|
||||||
<input name="staggeredVersionsPath" placeholder="" id="staggeredVersionsPath" class="form-control" type="text" ng-model="currentRepo.staggeredVersionsPath"></input>
|
<input name="staggeredVersionsPath" id="staggeredVersionsPath" class="form-control" type="text" ng-model="currentRepo.staggeredVersionsPath"></input>
|
||||||
<p translate class="help-block">Path where versions should be stored (leave empty for the default .stversions folder in the repository).</p>
|
<p translate class="help-block">Path where versions should be stored (leave empty for the default .stversions folder in the repository).</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -606,6 +606,7 @@
|
|||||||
<label translate for="MaxSendKbps">Outgoing Rate Limit (KiB/s)</label>
|
<label translate for="MaxSendKbps">Outgoing Rate Limit (KiB/s)</label>
|
||||||
<input id="MaxSendKbps" class="form-control" type="number" ng-model="tmpOptions.MaxSendKbps">
|
<input id="MaxSendKbps" class="form-control" type="number" ng-model="tmpOptions.MaxSendKbps">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
@@ -613,14 +614,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<span translate>Local Discovery</span> <input id="LocalAnnEnabled" type="checkbox" ng-model="tmpOptions.LocalAnnEnabled">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
@@ -628,6 +621,23 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<span translate>Automatic upgrades</span> <input id="AutoUpgradeEnabled" type="checkbox" ng-model="tmpOptions.AutoUpgradeEnabled">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<span translate>Local Discovery</span> <input id="LocalAnnEnabled" type="checkbox" ng-model="tmpOptions.LocalAnnEnabled">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label translate for="GlobalAnnServer">Global Discovery Server</label>
|
<label translate for="GlobalAnnServer">Global Discovery Server</label>
|
||||||
<input ng-disabled="!tmpOptions.GlobalAnnEnabled" id="GlobalAnnServer" class="form-control" type="text" ng-model="tmpOptions.GlobalAnnServer">
|
<input ng-disabled="!tmpOptions.GlobalAnnEnabled" id="GlobalAnnServer" class="form-control" type="text" ng-model="tmpOptions.GlobalAnnServer">
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -128,6 +128,7 @@ type OptionsConfiguration struct {
|
|||||||
UPnPRenewal int `xml:"upnpRenewalMinutes" default:"30"`
|
UPnPRenewal int `xml:"upnpRenewalMinutes" default:"30"`
|
||||||
URAccepted int `xml:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
|
URAccepted int `xml:"urAccepted"` // Accepted usage reporting version; 0 for off (undecided), -1 for off (permanently)
|
||||||
RestartOnWakeup bool `xml:"restartOnWakeup" default:"true"`
|
RestartOnWakeup bool `xml:"restartOnWakeup" default:"true"`
|
||||||
|
AutoUpgradeIntervalH int `xml:"autoUpgradeIntervalH" default:"12"` // 0 for off
|
||||||
|
|
||||||
Deprecated_RescanIntervalS int `xml:"rescanIntervalS,omitempty" json:"-"`
|
Deprecated_RescanIntervalS int `xml:"rescanIntervalS,omitempty" json:"-"`
|
||||||
Deprecated_UREnabled bool `xml:"urEnabled,omitempty" json:"-"`
|
Deprecated_UREnabled bool `xml:"urEnabled,omitempty" json:"-"`
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func TestDefaultValues(t *testing.T) {
|
|||||||
UPnPLease: 0,
|
UPnPLease: 0,
|
||||||
UPnPRenewal: 30,
|
UPnPRenewal: 30,
|
||||||
RestartOnWakeup: true,
|
RestartOnWakeup: true,
|
||||||
|
AutoUpgradeIntervalH: 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := New("test", node1)
|
cfg := New("test", node1)
|
||||||
@@ -130,6 +131,7 @@ func TestOverriddenValues(t *testing.T) {
|
|||||||
UPnPLease: 60,
|
UPnPLease: 60,
|
||||||
UPnPRenewal: 15,
|
UPnPRenewal: 15,
|
||||||
RestartOnWakeup: false,
|
RestartOnWakeup: false,
|
||||||
|
AutoUpgradeIntervalH: 24,
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := Load("testdata/overridenvalues.xml", node1)
|
cfg, err := Load("testdata/overridenvalues.xml", node1)
|
||||||
|
|||||||
@@ -16,5 +16,6 @@
|
|||||||
<upnpLeaseMinutes>60</upnpLeaseMinutes>
|
<upnpLeaseMinutes>60</upnpLeaseMinutes>
|
||||||
<upnpRenewalMinutes>15</upnpRenewalMinutes>
|
<upnpRenewalMinutes>15</upnpRenewalMinutes>
|
||||||
<restartOnWakeup>false</restartOnWakeup>
|
<restartOnWakeup>false</restartOnWakeup>
|
||||||
|
<autoUpgradeIntervalH>24</autoUpgradeIntervalH>
|
||||||
</options>
|
</options>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -26,8 +26,29 @@ var (
|
|||||||
ErrVersionUpToDate = errors.New("current version is up to date")
|
ErrVersionUpToDate = errors.New("current version is up to date")
|
||||||
ErrVersionUnknown = errors.New("couldn't fetch release information")
|
ErrVersionUnknown = errors.New("couldn't fetch release information")
|
||||||
ErrUpgradeUnsupported = errors.New("upgrade unsupported")
|
ErrUpgradeUnsupported = errors.New("upgrade unsupported")
|
||||||
|
ErrUpgradeInProgress = errors.New("upgrade already in progress")
|
||||||
|
upgradeUnlocked = make(chan bool, 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
upgradeUnlocked <- true
|
||||||
|
}
|
||||||
|
|
||||||
|
// A wrapper around actual implementations
|
||||||
|
func UpgradeTo(rel Release, archExtra string) error {
|
||||||
|
select {
|
||||||
|
case <-upgradeUnlocked:
|
||||||
|
err := upgradeTo(rel, archExtra)
|
||||||
|
// If we've failed to upgrade, unlock so that another attempt could be made
|
||||||
|
if err != nil {
|
||||||
|
upgradeUnlocked <- true
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
return ErrUpgradeInProgress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns 1 if a>b, -1 if a<b and 0 if they are equal
|
// Returns 1 if a>b, -1 if a<b and 0 if they are equal
|
||||||
func CompareVersions(a, b string) int {
|
func CompareVersions(a, b string) int {
|
||||||
arel, apre := versionParts(a)
|
arel, apre := versionParts(a)
|
||||||
|
|||||||
@@ -24,12 +24,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
||||||
func UpgradeTo(rel Release, archExtra string) error {
|
func upgradeTo(rel Release, archExtra string) error {
|
||||||
path, err := osext.Executable()
|
path, err := osext.Executable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
osName := runtime.GOOS
|
osName := runtime.GOOS
|
||||||
if osName == "darwin" {
|
if osName == "darwin" {
|
||||||
// We call the darwin release bundles macosx because that makes more
|
// We call the darwin release bundles macosx because that makes more
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
package upgrade
|
package upgrade
|
||||||
|
|
||||||
func UpgradeTo(rel Release, extra string) error {
|
func upgradeTo(rel Release, extra string) error {
|
||||||
return ErrUpgradeUnsupported
|
return ErrUpgradeUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
||||||
func UpgradeTo(rel Release, archExtra string) error {
|
func upgradeTo(rel Release, archExtra string) error {
|
||||||
path, err := osext.Executable()
|
path, err := osext.Executable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedRelease := fmt.Sprintf("syncthing-%s-%s%s-%s.", runtime.GOOS, runtime.GOARCH, archExtra, rel.Tag)
|
expectedRelease := fmt.Sprintf("syncthing-%s-%s%s-%s.", runtime.GOOS, runtime.GOARCH, archExtra, rel.Tag)
|
||||||
if debug {
|
if debug {
|
||||||
l.Debugf("expected release asset %q", expectedRelease)
|
l.Debugf("expected release asset %q", expectedRelease)
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
go test -tags integration -v
|
go test -tags integration -v -short
|
||||||
./test-http.sh
|
./test-http.sh
|
||||||
./test-merge.sh
|
./test-merge.sh
|
||||||
./test-delupd.sh
|
./test-delupd.sh
|
||||||
|
|||||||
+8
-4
@@ -17,10 +17,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
rand.Seed(42)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReadRand(bs []byte) (int, error) {
|
func ReadRand(bs []byte) (int, error) {
|
||||||
var r uint32
|
var r uint32
|
||||||
for i := range bs {
|
for i := range bs {
|
||||||
@@ -42,12 +38,20 @@ func main() {
|
|||||||
var files int
|
var files int
|
||||||
var maxexp int
|
var maxexp int
|
||||||
var srcname string
|
var srcname string
|
||||||
|
var random bool
|
||||||
|
|
||||||
flag.IntVar(&files, "files", 1000, "Number of files")
|
flag.IntVar(&files, "files", 1000, "Number of files")
|
||||||
flag.IntVar(&maxexp, "maxexp", 20, "Maximum file size (max = 2^n + 128*1024 B)")
|
flag.IntVar(&maxexp, "maxexp", 20, "Maximum file size (max = 2^n + 128*1024 B)")
|
||||||
flag.StringVar(&srcname, "src", "/usr/share/dict/words", "Source material")
|
flag.StringVar(&srcname, "src", "/usr/share/dict/words", "Source material")
|
||||||
|
flag.BoolVar(&random, "random", true, "When false, always generate the same set of file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if random {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
} else {
|
||||||
|
rand.Seed(42)
|
||||||
|
}
|
||||||
|
|
||||||
fd, err := os.Open(srcname)
|
fd, err := os.Open(srcname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBenchmarkTransfer(t *testing.T) {
|
func TestBenchmarkTransfer(t *testing.T) {
|
||||||
|
nfiles := 10000
|
||||||
|
if testing.Short() {
|
||||||
|
nfiles = 1000
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("Cleaning...")
|
log.Println("Cleaning...")
|
||||||
err := removeAll("s1", "s2", "h1/index", "h2/index")
|
err := removeAll("s1", "s2", "h1/index", "h2/index")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -21,7 +26,7 @@ func TestBenchmarkTransfer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Generating files...")
|
log.Println("Generating files...")
|
||||||
err = generateFiles("s1", 10000, 22, "../bin/syncthing")
|
err = generateFiles("s1", nfiles, 22, "../bin/syncthing")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user