mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Do not always save executable name in memory in sync package
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
//go:build !windows
|
||||
|
||||
package sync
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
var vanityEXE = os.Args[0]
|
||||
@@ -1,10 +0,0 @@
|
||||
//go:build windows
|
||||
|
||||
package sync
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var vanityEXE = os.Args[0][strings.LastIndex(os.Args[0], "\\")+1:]
|
||||
+2
-2
@@ -26,7 +26,7 @@ func getSSHClient(manualSync bool) (*ssh.Client, string, bool) {
|
||||
var sshUserConfig []string
|
||||
var missingValueError string
|
||||
if manualSync {
|
||||
missingValueError = "SSH settings not configured - run \"" + vanityEXE + " init\" to configure"
|
||||
missingValueError = joinErrorWithEXE("SSH settings not configured - run \"", " init\" to configure")
|
||||
} else {
|
||||
missingValueError = "0"
|
||||
}
|
||||
@@ -135,7 +135,7 @@ func getRemoteDataFromClient(manualSync bool) (map[string]int64, []string, []str
|
||||
clientDeviceID, _ := os.ReadDir(backend.ConfigDir + backend.PathSeparator + "devices")
|
||||
if len(clientDeviceID) == 0 {
|
||||
if manualSync {
|
||||
fmt.Println(backend.AnsiError + "Sync failed - No device ID found; run \"" + vanityEXE + " init\" to generate a device ID" + backend.AnsiReset)
|
||||
fmt.Println(joinErrorWithEXE("Sync failed - No device ID found; run \"", " init\" to generate a device ID"))
|
||||
os.Exit(1)
|
||||
} else {
|
||||
backend.Exit(0) // exit silently if the sync job was called automatically, as the user may just be in offline mode
|
||||
|
||||
@@ -24,7 +24,7 @@ func WalkEntryDir() ([]string, []string) {
|
||||
// check for errors encountered while walking directory
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+vanityEXE, "init"+"\" to create it"+backend.AnsiReset)
|
||||
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+os.Args[0], "init"+"\" to create it"+backend.AnsiReset)
|
||||
} else {
|
||||
// otherwise, print the source of the error
|
||||
fmt.Println(backend.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + backend.AnsiReset)
|
||||
@@ -47,3 +47,8 @@ func WalkEntryDir() ([]string, []string) {
|
||||
|
||||
return fileList, dirList
|
||||
}
|
||||
|
||||
// joinErrorWithEXE joins and returns the two strings it is provided (in error format) with the executable name inserted between them
|
||||
func joinErrorWithEXE(firstHalf, secondHalf string) string {
|
||||
return backend.AnsiError + firstHalf + os.Args[0] + secondHalf + backend.AnsiReset
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func WalkEntryDir() ([]string, []string) {
|
||||
// check for errors encountered while walking directory
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+vanityEXE, "init"+"\" to create it"+backend.AnsiReset)
|
||||
fmt.Println(joinErrorWithEXE("The entry directory does not exist - run \"", " init"+"\" to create it"))
|
||||
} else {
|
||||
// otherwise, print the source of the error
|
||||
fmt.Println(backend.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + backend.AnsiReset)
|
||||
@@ -48,3 +48,8 @@ func WalkEntryDir() ([]string, []string) {
|
||||
|
||||
return fileList, dirList
|
||||
}
|
||||
|
||||
// joinErrorWithEXE joins and returns the two strings it is provided (in error format) with the executable name inserted between them
|
||||
func joinErrorWithEXE(firstHalf, secondHalf string) string {
|
||||
return backend.AnsiError + firstHalf + os.Args[0][strings.LastIndex(os.Args[0], "\\")+1:] + secondHalf + backend.AnsiReset
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user