From cbde1006ebf2a01d3950f7a13bb79bea15b105d4 Mon Sep 17 00:00:00 2001 From: Jim Salem Date: Tue, 22 Mar 2016 23:09:33 -0400 Subject: [PATCH 1/4] Added -nodelete argument --- main.go | 16 +++++++++++----- rsync.go | 7 +++++-- version.go | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 470a7bb..01933e4 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,7 @@ func main() { var verbose = flag.Bool("verbose", false, "Verbose output") var srcpath = flag.String("src", pwd, "Source directory") var dstpath = flag.String("dst", pathpkg.Join("/rsync", pwd), "Destination directory") + var nodelete = flag.Bool("nodelete", false, "Don't delete pre-existing files in destination") flag.Parse() @@ -62,12 +63,12 @@ func main() { rsyncEndpoint := via fmt.Printf("Syncing %s (local) to %s (%s)\n", *srcpath, *dstpath, rsyncEndpoint) - Sync(rsyncEndpoint, 0, rpath, rpathDir, *verbose) // initial sync + Sync(rsyncEndpoint, 0, rpath, rpathDir, *nodelete, *verbose) // initial sync if *watch { fmt.Println("Watching for file changes ...") Watch(rpath, func(id uint64, path string, flags []string) { - Sync(rsyncEndpoint, 0, rpath, rpathDir, true) + Sync(rsyncEndpoint, 0, rpath, rpathDir, *nodelete, true) }) } @@ -83,13 +84,18 @@ func main() { Provision(machineName, *verbose) RunSSHCommand(machineName, "sudo mkdir -p "+rpathDir, *verbose) - fmt.Printf("Syncing %s (local) to %s (docker-machine %s)\n", *srcpath, *dstpath, machineName) - Sync(machineName, port, rpath, rpathDir, *verbose) // initial sync + if *nodelete { + fmt.Printf("Copying") + } else { + fmt.Printf("Syncing") + } + fmt.Printf(" %s (local) to %s (docker-machine %s)\n", *srcpath, *dstpath, machineName) + Sync(machineName, port, rpath, rpathDir, *nodelete, *verbose) // initial sync if *watch { fmt.Println("Watching for file changes ...") Watch(rpath, func(id uint64, path string, flags []string) { - Sync(machineName, port, rpath, rpathDir, true) + Sync(machineName, port, rpath, rpathDir, *nodelete, true) }) } } diff --git a/rsync.go b/rsync.go index f20d072..7311a86 100644 --- a/rsync.go +++ b/rsync.go @@ -10,7 +10,7 @@ import ( var lastSyncError = "" -func Sync(via string, port uint, src, dst string, verbose bool) { +func Sync(via string, port uint, src, dst string, nodelete bool, verbose bool) { args := []string{ // "--verbose", // "--stats", @@ -19,7 +19,6 @@ func Sync(via string, port uint, src, dst string, verbose bool) { "--times", "--inplace", "--itemize-changes", - "--delete", "--force", "--executability", "--compress", @@ -41,6 +40,10 @@ func Sync(via string, port uint, src, dst string, verbose bool) { args = append(args, src, "docker@localhost:"+dst) } + if ! nodelete { + args = append(args, "--delete") + } + command := "rsync " + strings.Join(args, " ") // fmt.Println("/bin/sh", "-c", command) diff --git a/version.go b/version.go index d4847b4..e93374e 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -const Version = "0.1.1" +const Version = "0.1.2" From c16cefc33555dfc0315a2ae79df8d9dd47fddca1 Mon Sep 17 00:00:00 2001 From: Jim Salem Date: Tue, 22 Mar 2016 23:13:57 -0400 Subject: [PATCH 2/4] revert changes to fsevents library --- watch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/watch.go b/watch.go index ebb5542..86e6fb4 100644 --- a/watch.go +++ b/watch.go @@ -1,7 +1,7 @@ package main import ( - "github.com/fsnotify/fsevents" + "github.com/mattes/fsevents" "sort" "time" ) From 1412b3bec05db0d4babc630c2ca949d2ed72539c Mon Sep 17 00:00:00 2001 From: Jim Salem Date: Thu, 21 Apr 2016 14:08:09 -0400 Subject: [PATCH 3/4] Cleanup merge errors --- rsync.go | 2 +- watch.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rsync.go b/rsync.go index 6792a38..952d42f 100644 --- a/rsync.go +++ b/rsync.go @@ -9,7 +9,7 @@ import ( var lastSyncError = "" -func Sync(via string, port uint, src, dst string, nodelete bool, verbose bool) { +func Sync(via string, c SSHCredentials, src, dst string, nodelete bool, verbose bool) { args := []string{ // "--verbose", // "--stats", diff --git a/watch.go b/watch.go index 9cf4e99..e9dd98e 100644 --- a/watch.go +++ b/watch.go @@ -1,7 +1,7 @@ package main import ( - "github.com/mattes/fsevents" + "github.com/fsnotify/fsevents" "sort" "time" ) From 203f61d9abaf7e5b68b7a7371621ff25d87ee314 Mon Sep 17 00:00:00 2001 From: Jim Salem Date: Thu, 21 Apr 2016 14:09:45 -0400 Subject: [PATCH 4/4] Minor merge cleanup --- version.go | 1 - 1 file changed, 1 deletion(-) diff --git a/version.go b/version.go index b41775b..917cae5 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,3 @@ package main const Version = "0.1.3" -