~whynothugo/autovdirsyncer

052ff61d7ee780b48d8e80a1af556a8fee086559 — Hugo Osvaldo Barrera 3 years ago 0192d6c
Use constants for predefined intervals
1 files changed, 6 insertions(+), 18 deletions(-)

M main.go
M main.go => main.go +6 -18
@@ 11,14 11,17 @@ import (
	"sync"
	"time"

	"github.com/fsnotify/fsnotify"
	vdirsyncer "git.sr.ht/~whynothugo/autovdirsyncer/vdirsyncer"
	"github.com/fsnotify/fsnotify"
)

const (
	passiveInterval = time.Minute * 15 // Period between automatic syncs if nothing happens.
	activeDebounce  = time.Second * 2  // Period to debounce when changes are happening.
)

var (
	vdirsyncerIsRunning sync.Mutex
	passiveInterval     time.Duration // Period between automatic syncs if nothing happens.
	activeDebounce      time.Duration // Period to debounce when changes are happening.
)

func runSynchronization() {


@@ 115,21 118,6 @@ func addDirsToWatcher(watcher *fsnotify.Watcher, dirsToWatch []string) error {
}

func main() {
	var err error

	// Frequency with which updates run.
	passiveInterval, err = time.ParseDuration("15m")
	if err != nil {
		fmt.Println(err)
		os.Exit(2)
	}

	activeDebounce, err = time.ParseDuration("2s")
	if err != nil {
		fmt.Println(err)
		os.Exit(2)
	}

	// Watcher that monitors for local fs changes.
	watcher, err := fsnotify.NewWatcher()
	if err != nil {