mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Fix Windows sync (WalkEntryDir now returns only UNIX-style separators); fix setting remote mod time on remote files when downloading; fix server binary compilation; fix init failing silently during SSH configuration
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ func main() {
|
|||||||
fmt.Print(backend.EntryRoot + "\x1d" + strconv.FormatBool(backend.IsWindows))
|
fmt.Print(backend.EntryRoot + "\x1d" + strconv.FormatBool(backend.IsWindows))
|
||||||
case "init":
|
case "init":
|
||||||
// create the necessary directories for libmuttonserver to function
|
// create the necessary directories for libmuttonserver to function
|
||||||
backend.DirInit()
|
backend.DirInit(false)
|
||||||
os.MkdirAll(backend.ConfigDir+backend.PathSeparator+"deletions", 0700)
|
os.MkdirAll(backend.ConfigDir+backend.PathSeparator+"deletions", 0700)
|
||||||
case "version", "-v":
|
case "version", "-v":
|
||||||
versionServer()
|
versionServer()
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ func determineIndentation(skippedDirList []bool, dirList []string, currentDirInd
|
|||||||
var lastPrefixIndex int // tracks the index (in both skippedDirList and dirList) of the last displayed parent directory
|
var lastPrefixIndex int // tracks the index (in both skippedDirList and dirList) of the last displayed parent directory
|
||||||
var trimmedDirectory = dirList[currentDirIndex]
|
var trimmedDirectory = dirList[currentDirIndex]
|
||||||
|
|
||||||
// determine initial indentation multiplier based on PathSeparator occurrences
|
// determine initial indentation multiplier based on "/" occurrences
|
||||||
indent := strings.Count(trimmedDirectory, backend.PathSeparator) - 1 // subtract 1 to avoid indenting root-level directories
|
indent := strings.Count(trimmedDirectory, "/") - 1 // subtract 1 to avoid indenting root-level directories
|
||||||
|
|
||||||
for i, skipped := range skippedDirList[:currentDirIndex] { // checks each skipped directory to determine if it is a parent to the current directory
|
for i, skipped := range skippedDirList[:currentDirIndex] { // checks each skipped directory to determine if it is a parent to the current directory
|
||||||
if strings.HasPrefix(trimmedDirectory, dirList[i]+backend.PathSeparator) { // if the current directory is the child of this iteration's directory...
|
if strings.HasPrefix(trimmedDirectory, dirList[i]+"/") { // if the current directory is the child of this iteration's directory...
|
||||||
if skipped { // ...and this iteration's directory was skipped...
|
if skipped { // ...and this iteration's directory was skipped...
|
||||||
subtractor++ // increment the subtractor to indicate that the visual indentation should be reduced
|
subtractor++ // increment the subtractor to indicate that the visual indentation should be reduced
|
||||||
} else {
|
} else {
|
||||||
@@ -106,7 +106,7 @@ func EntryListGen() {
|
|||||||
|
|
||||||
// check if next directory is within the current one
|
// check if next directory is within the current one
|
||||||
if dirListLength > i+1 {
|
if dirListLength > i+1 {
|
||||||
if nextDir := dirList[i+1]; directory == nextDir[:strings.LastIndex(nextDir, backend.PathSeparator)] {
|
if nextDir := dirList[i+1]; directory == nextDir[:strings.LastIndex(nextDir, "/")] {
|
||||||
containsSubdirectory = true
|
containsSubdirectory = true
|
||||||
} else {
|
} else {
|
||||||
containsSubdirectory = false
|
containsSubdirectory = false
|
||||||
@@ -120,14 +120,14 @@ func EntryListGen() {
|
|||||||
for _, file := range fileList {
|
for _, file := range fileList {
|
||||||
|
|
||||||
// print the current file if it belongs in the current directory - otherwise, break the loop and move on to the next directory
|
// print the current file if it belongs in the current directory - otherwise, break the loop and move on to the next directory
|
||||||
if lastSlash := strings.LastIndex(file, backend.PathSeparator) + 1; file[:lastSlash-1] == directory {
|
if lastSlash := strings.LastIndex(file, "/") + 1; file[:lastSlash-1] == directory {
|
||||||
|
|
||||||
// print directory header if this is the first run of the loop
|
// print directory header if this is the first run of the loop
|
||||||
if !containsFiles {
|
if !containsFiles {
|
||||||
containsFiles = true
|
containsFiles = true
|
||||||
skippedDirList[i] = false // the directory header is being printed, indicate that it is not being skipped
|
skippedDirList[i] = false // the directory header is being printed, indicate that it is not being skipped
|
||||||
indent, vanityDirectory = determineIndentation(skippedDirList, dirList, i) // calculate the final indentation multiplier
|
indent, vanityDirectory = determineIndentation(skippedDirList, dirList, i) // calculate the final indentation multiplier
|
||||||
printDirectoryHeader(vanityDirectory, indent)
|
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+backend.AnsiReset+"\n", vanityDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, indent, colorAlternator)
|
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, indent, colorAlternator)
|
||||||
@@ -139,7 +139,7 @@ func EntryListGen() {
|
|||||||
if dirListLength > 1 { // and directories besides the root-level exist... display directory header and empty directory warning
|
if dirListLength > 1 { // and directories besides the root-level exist... display directory header and empty directory warning
|
||||||
skippedDirList[i] = false // the directory header is being printed, indicate that it is not being skipped
|
skippedDirList[i] = false // the directory header is being printed, indicate that it is not being skipped
|
||||||
indent, vanityDirectory = determineIndentation(skippedDirList, dirList, i) // calculate the final indentation multiplier
|
indent, vanityDirectory = determineIndentation(skippedDirList, dirList, i) // calculate the final indentation multiplier
|
||||||
printDirectoryHeader(vanityDirectory, indent)
|
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+backend.AnsiReset+"\n", vanityDirectory)
|
||||||
fmt.Print(strings.Repeat(" ", indent*2) + ansiEmptyDirectoryWarning + "-empty directory-" + backend.AnsiReset)
|
fmt.Print(strings.Repeat(" ", indent*2) + ansiEmptyDirectoryWarning + "-empty directory-" + backend.AnsiReset)
|
||||||
} else { // warn if the only thing that exists is the root-level directory
|
} else { // warn if the only thing that exists is the root-level directory
|
||||||
fmt.Print("\n\nNothing's here! For help creating your first entry, run \"mutn help\".")
|
fmt.Print("\n\nNothing's here! For help creating your first entry, run \"mutn help\".")
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
//go:build !windows
|
|
||||||
|
|
||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/rwinkhart/MUTN/src/backend"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func printDirectoryHeader(vanityDirectory string, indent int) {
|
|
||||||
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+backend.AnsiReset+"\n", vanityDirectory)
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
//go:build windows
|
|
||||||
|
|
||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/rwinkhart/MUTN/src/backend"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func printDirectoryHeader(vanityDirectory string, indent int) {
|
|
||||||
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+backend.AnsiReset+"\n", strings.ReplaceAll(vanityDirectory, backend.PathSeparator, "/"))
|
|
||||||
}
|
|
||||||
+1
-1
@@ -40,7 +40,7 @@ func TempInitCli() {
|
|||||||
sshKeyProtected := inputBinary("Is the identity file password-protected?")
|
sshKeyProtected := inputBinary("Is the identity file password-protected?")
|
||||||
|
|
||||||
// write config file
|
// write config file
|
||||||
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshKey": sshKey, "sshKeyProtected": strconv.FormatBool(sshKeyProtected)}, false)
|
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshKey": sshKey, "sshKeyProtected": strconv.FormatBool(sshKeyProtected), "sshEntryRoot": "null", "sshIsWindows": "null"}, false)
|
||||||
|
|
||||||
// generate device ID
|
// generate device ID
|
||||||
sshEntryRoot, sshIsWindows := sync.DeviceIDGen()
|
sshEntryRoot, sshIsWindows := sync.DeviceIDGen()
|
||||||
|
|||||||
Reference in New Issue
Block a user