Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Commit

Permalink
Pass ssh flags to rsync
Browse files Browse the repository at this point in the history
Resolves #19
  • Loading branch information
ammario committed Apr 20, 2019
1 parent 3f4919f commit afc57e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ chmod +x `+codeServerPath+`
flog.Info("synced settings in %s", time.Since(start))

flog.Info("syncing extensions")
err = syncExtensions(host)
err = syncExtensions(host, *sshFlags)
if err != nil {
flog.Fatal("failed to sync extensions: %v", err)
}
Expand Down Expand Up @@ -208,24 +208,24 @@ func syncUserSettings(host string) error {
return rsync(localConfDir+"/", remoteSettingsDir, host, "workspaceStorage", "logs", "CachedData")
}

func syncExtensions(host string) error {
func syncExtensions(host string, sshFlags string) error {
localExtensionsDir, err := extensionsDir()
if err != nil {
return err
}
const remoteExtensionsDir = ".local/share/code-server/extensions"

return rsync(localExtensionsDir+"/", remoteExtensionsDir, host)
return rsync(localExtensionsDir+"/", remoteExtensionsDir, sshFlags, host)
}

func rsync(src string, dest string, host string, excludePaths ...string) error {
func rsync(src string, dest string, host string, sshFlags string, excludePaths ...string) error {
remoteDest := fmt.Sprintf("%s:%s", host, dest)
excludeFlags := make([]string, len(excludePaths))
for i, path := range excludePaths {
excludeFlags[i] = "--exclude=" + path
}

cmd := exec.Command("rsync", append(excludeFlags, "-azv", "--copy-unsafe-links", src, remoteDest)...)
cmd := exec.Command("rsync", append(excludeFlags, "-e", "ssh "+sshFlags, "-azv", "--copy-unsafe-links", src, remoteDest)...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
Expand Down

0 comments on commit afc57e9

Please sign in to comment.