From 231e3c69f4e921cb6ee888cf0a468246ab0a9631 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Tue, 15 Mar 2016 17:58:51 +0100 Subject: [PATCH] Version 1.1.0 Updated all libraries to the current versions. Thus, the deletion of remote directories now works. Also, several additional bugs are now fixed by these external libraries. Thanks to the contributors for the good work. --- Main.go | 200 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/Main.go b/Main.go index c8b9389..a17cce2 100644 --- a/Main.go +++ b/Main.go @@ -1,100 +1,100 @@ -package main - -import ( - "fmt" - "github.com/SommerEngineering/Sync/Sync" - "golang.org/x/crypto/ssh" - "log" - "os" - "runtime" -) - -func main() { - - // Show the current version: - log.Println(`Sync v1.0.0`) - - // Allow Go to use all CPUs: - runtime.GOMAXPROCS(runtime.NumCPU()) - - // Read the configuration from the command-line args: - readFlags() - - // Check if the directories are provided: - if localDir == `` || remoteDir == `` { - log.Println(`Please provide the local and remote directory.`) - return - } - - // Should I use the current working dir? - if localDir == `.` { - if currentWD, currentWDError := os.Getwd(); currentWDError != nil { - log.Println("Cannot use the current working directory as local directory: " + currentWDError.Error()) - return - } else { - log.Println("I use the current working directory as local directory: " + currentWD) - localDir = currentWD - } - } - - // Remove trailing separators from both directories - localDir = correctPath(localDir) - remoteDir = correctPath(remoteDir) - - // Check if local dir exist - if dirInfo, dirError := os.Stat(localDir); dirError != nil { - log.Println("There is an error with the local directory: " + dirError.Error()) - return - } else { - if !dirInfo.IsDir() { - log.Println("There is an error with the local directory: You provided a file instead!") - return - } - } - - // Check if the password was provided: - for true { - if password == `` { - // Promt for the password: - fmt.Print(`Please provide the password for the connection: `) - fmt.Scanln(&password) - } else { - break - } - } - - // Give some information about the state - if supervised { - log.Println("I use the supervised mode.") - } else { - log.Println("I do not use the supervised mode.") - } - - if pushOnly { - log.Println("I use the push only mode i.e. backup mode. Any remote change will be ignored.") - } else { - log.Println("I use the full mode and consider also remote changes.") - } - - // Create the SSH configuration: - Sync.SetPassword4Callback(password) - config := &ssh.ClientConfig{ - User: username, - Auth: []ssh.AuthMethod{ - ssh.Password(password), - ssh.PasswordCallback(Sync.PasswordCallback), - ssh.KeyboardInteractive(Sync.KeyboardInteractiveChallenge), - }, - } - - // Connect to the SSH server: - ssh := Sync.ConnectSSH(config, serverAddrString) - if ssh == nil { - log.Println(`It was not possible to connect to the SSH server.`) - return - } - - defer ssh.Close() - Sync.Synchronise(ssh, supervised, pushOnly, localDir, remoteDir) - log.Println("Synchronising done.") -} +package main + +import ( + "fmt" + "github.com/SommerEngineering/Sync/Sync" + "golang.org/x/crypto/ssh" + "log" + "os" + "runtime" +) + +func main() { + + // Show the current version: + log.Println(`Sync v1.1.0`) + + // Allow Go to use all CPUs: + runtime.GOMAXPROCS(runtime.NumCPU()) + + // Read the configuration from the command-line args: + readFlags() + + // Check if the directories are provided: + if localDir == `` || remoteDir == `` { + log.Println(`Please provide the local and remote directory.`) + return + } + + // Should I use the current working dir? + if localDir == `.` { + if currentWD, currentWDError := os.Getwd(); currentWDError != nil { + log.Println("Cannot use the current working directory as local directory: " + currentWDError.Error()) + return + } else { + log.Println("I use the current working directory as local directory: " + currentWD) + localDir = currentWD + } + } + + // Remove trailing separators from both directories + localDir = correctPath(localDir) + remoteDir = correctPath(remoteDir) + + // Check if local dir exist + if dirInfo, dirError := os.Stat(localDir); dirError != nil { + log.Println("There is an error with the local directory: " + dirError.Error()) + return + } else { + if !dirInfo.IsDir() { + log.Println("There is an error with the local directory: You provided a file instead!") + return + } + } + + // Check if the password was provided: + for true { + if password == `` { + // Promt for the password: + fmt.Print(`Please provide the password for the connection: `) + fmt.Scanln(&password) + } else { + break + } + } + + // Give some information about the state + if supervised { + log.Println("I use the supervised mode.") + } else { + log.Println("I do not use the supervised mode.") + } + + if pushOnly { + log.Println("I use the push only mode i.e. backup mode. Any remote change will be ignored.") + } else { + log.Println("I use the full mode and consider also remote changes.") + } + + // Create the SSH configuration: + Sync.SetPassword4Callback(password) + config := &ssh.ClientConfig{ + User: username, + Auth: []ssh.AuthMethod{ + ssh.Password(password), + ssh.PasswordCallback(Sync.PasswordCallback), + ssh.KeyboardInteractive(Sync.KeyboardInteractiveChallenge), + }, + } + + // Connect to the SSH server: + ssh := Sync.ConnectSSH(config, serverAddrString) + if ssh == nil { + log.Println(`It was not possible to connect to the SSH server.`) + return + } + + defer ssh.Close() + Sync.Synchronise(ssh, supervised, pushOnly, localDir, remoteDir) + log.Println("Synchronising done.") +}