bug fixes, exclude by regex pattern option

This commit is contained in:
2019-09-21 19:52:33 -04:00
parent 8067eb0bfe
commit 0af56e8306
4 changed files with 60 additions and 20 deletions

18
cli.go
View File

@@ -7,6 +7,7 @@ import (
"github.com/urfave/cli"
"os"
"os/signal"
"regexp"
"sync"
"syscall"
"time"
@@ -14,7 +15,7 @@ import (
func globalInit() {
//TODO cmdline flag
logrus.SetLevel(logrus.TraceLevel)
//logrus.SetLevel(logrus.TraceLevel)
}
func main() {
@@ -32,6 +33,7 @@ func main() {
var watchDir string
var transfers int
var tarMaxCount int
var excludePattern string
var inactiveDelay time.Duration
app.Flags = []cli.Flag{
@@ -47,6 +49,11 @@ func main() {
"Example: \"rclone move %file remote:/beem/%dir\"",
Destination: &cmdString,
},
cli.StringFlag{
Name: "exclude, e",
Usage: "Exclude files that match this regex pattern",
Destination: &excludePattern,
},
cli.DurationFlag{
Name: "wait, w",
Usage: "Files will be beemed after `DELAY` of inactivity",
@@ -84,6 +91,11 @@ func main() {
tarMaxCount: tarMaxCount,
}
if excludePattern != "" {
beemer.excludePattern, _ = regexp.Compile(excludePattern)
logrus.Infof("Exclude pattern is /%s/", excludePattern)
}
beemer.initTempDir()
beemer.watcher, _ = fsnotify.NewWatcher()
@@ -105,7 +117,9 @@ func main() {
go beemer.work()
}
go beemer.tarWork()
if tarMaxCount > 1 {
go beemer.tarWork()
}
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT)