Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-time Filesystem Notifications - WIP #2807

Closed
wants to merge 21 commits into from
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5590f19
Add the github.com/zillode/notify dependency
plouj Feb 28, 2016
fa329a2
util.go: Avoid overloading the log variable
plouj Mar 17, 2016
40060d9
util.go:startInstance: show log path
plouj Mar 21, 2016
a4e4335
util.go: Add assertFileCount
plouj Mar 21, 2016
89dc4c4
util.go: Helpers: createDirectories createFiles rescan waitForSync ge…
plouj Mar 21, 2016
a9c40cf
util.go: Add makeTempFilename
plouj Mar 26, 2016
e731795
start an FsWatcher
plouj Feb 22, 2016
f3034b9
Pass ignore.Matcher to FSWatcher to filter filesystem events
imsodin Oct 29, 2016
e4c6dd4
Check if event is ignored before calling speedUpNotifyTimer
imsodin Oct 29, 2016
5a89361
Prepend log messages with folderID
imsodin Oct 29, 2016
7d01b3c
Recursive notify watches
imsodin Oct 30, 2016
a7e0897
Aggregate immediately on every incoming event (based on syncthing-ino…
imsodin Nov 13, 2016
5d9285a
Inform about which folder failed and print durations with units
imsodin Nov 15, 2016
cb68728
fswatcher: Fix race in FsWatcher.notifyModelChan
plouj Nov 22, 2016
4231cbd
fswatcher: Improve aggregation debug messages
plouj Nov 24, 2016
9b6bcc8
fswatcher: Rename dirPath to parentPath
plouj Nov 25, 2016
0adc64c
Add function extractOldEvents to unclutter actOnTimer
imsodin Nov 25, 2016
54373ba
Fix race on updating ignores
imsodin Jan 28, 2017
0765c45
Adapt logging scheme from rwfolder.go
imsodin Jan 28, 2017
114c04a
Don't install watches on ignored files and update notify
imsodin Nov 15, 2016
2e8f3a3
Add Stop() method to remove FS watches when terminated
imsodin Jan 28, 2017
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1023,6 +1023,7 @@ func defaultConfig(myName string) config.Configuration {
defaultFolder = config.NewFolderConfiguration("default", locations[locDefFolder])
defaultFolder.Label = "Default Folder"
defaultFolder.RescanIntervalS = 60
defaultFolder.LongRescanIntervalS = 60 * 60
defaultFolder.MinDiskFreePct = 1
defaultFolder.Devices = []config.FolderDeviceConfiguration{{DeviceID: myID}}
defaultFolder.AutoNormalize = true
@@ -369,6 +369,10 @@ <h4 class="panel-title">
<th><span class="fa fa-fw fa-refresh"></span>&nbsp;<span translate>Rescan Interval</span></th>
<td class="text-right">{{folder.rescanIntervalS}} s</td>
</tr>
<tr ng-if="folder.longRescanIntervalS != 3600">

This comment has been minimized.

Copy link
@calmh

calmh Feb 13, 2017

Member

I don't think we should expose this here, especially not with a cryptic camelcased name. See also below about the settings modal.

<th><span class="fa fa-fw fa-refresh"></span>&nbsp;<span translate>LongRescan Interval</span></th>
<td class="text-right">{{folder.longRescanIntervalS}} s</td>
</tr>
<tr ng-if="folder.order != 'random'">
<th><span class="fa fa-fw fa-sort"></span>&nbsp;<span translate>File Pull Order</span></th>
<td class="text-right" ng-switch="folder.order">
@@ -1388,6 +1388,7 @@ angular.module('syncthing.core')
selectedDevices: {},
type: "readwrite",
rescanIntervalS: 60,
longRescanIntervalS: 3600,
minDiskFreePct: 1,
maxConflicts: 10,
fsync: true,
@@ -1416,6 +1417,7 @@ angular.module('syncthing.core')
label: folderLabel,
selectedDevices: {},
rescanIntervalS: 60,
longRescanIntervalS: 3600,
minDiskFreePct: 1,
maxConflicts: 10,
fsync: true,
@@ -73,6 +73,13 @@
<span translate ng-if="!folderEditor.rescanIntervalS.$valid && folderEditor.rescanIntervalS.$dirty">The rescan interval must be a non-negative number of seconds.</span>
</p>
</div>
<div class="form-group" ng-class="{'has-error': folderEditor.longRescanIntervalS.$invalid && folderEditor.longRescanIntervalS.$dirty}">

This comment has been minimized.

Copy link
@calmh

calmh Feb 13, 2017

Member

I don't think we should expose this here. I would suggest something like a checkbox "Use Filesystem Notifications" in addition to the existing "Rescan Interval" box. When checked, rescan interval is greyed out. The long rescan interval lives in the advanced/hidden options only.

Challenge: GUI needs to know whether filesystem notifications are supported at all, in order to show the checkbox...

<label for="longRescanIntervalS"><span translate>Long Rescan Interval</span> (s)</label>
<input name="longRescanIntervalS" id="longRescanIntervalS" class="form-control" type="number" ng-model="currentFolder.longRescanIntervalS" required min="0">
<p class="help-block">
<span translate ng-if="!folderEditor.longRescanIntervalS.$valid && folderEditor.longRescanIntervalS.$dirty">The rescan interval must be a non-negative number of seconds.</span>
</p>
</div>
<div class="form-group" ng-class="{'has-error': folderEditor.minDiskFreePct.$invalid && folderEditor.minDiskFreePct.$dirty}">
<label for="minDiskFreePct"><span translate>Minimum Free Disk Space</span> (0.0 - 100.0%)</label>
<input name="minDiskFreePct" id="minDiskFreePct" class="form-control" type="number" ng-model="currentFolder.minDiskFreePct" required min="0.0" max="100.0">
@@ -24,6 +24,7 @@ type FolderConfiguration struct {
Type FolderType `xml:"type,attr" json:"type"`
Devices []FolderDeviceConfiguration `xml:"device" json:"devices"`
RescanIntervalS int `xml:"rescanIntervalS,attr" json:"rescanIntervalS"`
LongRescanIntervalS int `xml:"longRescanIntervalS,attr" json:"longRescanIntervalS"`
IgnorePerms bool `xml:"ignorePerms,attr" json:"ignorePerms"`
AutoNormalize bool `xml:"autoNormalize,attr" json:"autoNormalize"`
MinDiskFreePct float64 `xml:"minDiskFreePct" json:"minDiskFreePct"`
@@ -143,6 +144,12 @@ func (f *FolderConfiguration) prepare() {
f.RescanIntervalS = 0
}

if f.LongRescanIntervalS > MaxRescanIntervalS {
f.LongRescanIntervalS = MaxRescanIntervalS
} else if f.LongRescanIntervalS < 0 {
f.LongRescanIntervalS = 0
}

if f.Versioning.Params == nil {
f.Versioning.Params = make(map[string]string)
}
@@ -0,0 +1,24 @@
// Copyright (C) 2016 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.

package fswatcher

import (
"os"
"strings"

"github.com/syncthing/syncthing/lib/logger"
)

var facilityName = "fswatcher"

var (
l = logger.DefaultLogger.NewFacility(facilityName, "Filesystem event watcher")
)

func init() {
l.SetDebug(facilityName, strings.Contains(os.Getenv("STTRACE"), facilityName) || os.Getenv("STTRACE") == "all")
}
@@ -0,0 +1,19 @@
// Copyright (C) 2016 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.

package fswatcher

import (
"syscall"
)

func interpretNotifyWatchError(err error, folder string) error {

This comment has been minimized.

Copy link
@calmh

calmh Feb 13, 2017

Member

I'd typically expect this as an isWatchesTooFew(err error) bool that could be used appropriately by someone inspecting a returned error, instead of something that transforms the error, cf. os.IsNotExist and similar.

if errno, converted := err.(syscall.Errno); converted &&
errno == 24 || errno == 28 {
return WatchesLimitTooLowError(folder)
}
return err
}
@@ -0,0 +1,13 @@
// Copyright (C) 2016 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.

// +build !linux

package fswatcher

func interpretNotifyWatchError(err error, folder string) error {
return err
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.