Address JetBrains warnings

This commit is contained in:
2025-12-26 19:12:48 -05:00
parent b591e2ef5a
commit 2880ce2823
10 changed files with 34 additions and 44 deletions
+11 -13
View File
@@ -27,29 +27,29 @@ import (
// Only supports key-based authentication (passwords are supported for CLI-based implementations).
func GetSSHClient() (*ssh.Client, bool, *bool, *string, *string, error) {
// get SSH config info
cfg, err := cfg.LoadConfig()
config, err := cfg.LoadConfig()
if err != nil {
return nil, false, nil, nil, nil, errors.New("unable to parse SSH config: " + err.Error())
}
if *cfg.Libmutton.OfflineMode {
if *config.Libmutton.OfflineMode {
return nil, true, nil, nil, nil, nil
}
// read private key
key, err := os.ReadFile(*cfg.Libmutton.SSHKeyPath)
key, err := os.ReadFile(*config.Libmutton.SSHKeyPath)
if err != nil {
return nil, false, nil, nil, nil, errors.New("unable to read private key: " + *cfg.Libmutton.SSHKeyPath)
return nil, false, nil, nil, nil, errors.New("unable to read private key: " + *config.Libmutton.SSHKeyPath)
}
// parse private key
var parsedKey ssh.Signer
if !*cfg.Libmutton.SSHKeyProtected {
if !*config.Libmutton.SSHKeyProtected {
parsedKey, err = ssh.ParsePrivateKey(key)
} else {
parsedKey, err = ssh.ParsePrivateKeyWithPassphrase(key, global.GetPassword("Enter password for your SSH keyfile:"))
}
if err != nil {
return nil, false, nil, nil, nil, errors.New("unable to parse private key: " + *cfg.Libmutton.SSHKeyPath)
return nil, false, nil, nil, nil, errors.New("unable to parse private key: " + *config.Libmutton.SSHKeyPath)
}
// read known hosts file
@@ -61,7 +61,7 @@ func GetSSHClient() (*ssh.Client, bool, *bool, *string, *string, error) {
// configure SSH client
sshConfig := &ssh.ClientConfig{
User: *cfg.Libmutton.SSHUser,
User: *config.Libmutton.SSHUser,
Auth: []ssh.AuthMethod{
ssh.PublicKeys(parsedKey),
},
@@ -70,12 +70,12 @@ func GetSSHClient() (*ssh.Client, bool, *bool, *string, *string, error) {
}
// connect to SSH server
sshClient, err := ssh.Dial("tcp", *cfg.Libmutton.SSHIP+":"+*cfg.Libmutton.SSHPort, sshConfig)
sshClient, err := ssh.Dial("tcp", *config.Libmutton.SSHIP+":"+*config.Libmutton.SSHPort, sshConfig)
if err != nil {
return nil, false, nil, nil, nil, errors.New("unable to connect to remote server: " + err.Error())
}
return sshClient, false, cfg.Libmutton.SSHIsWindows, cfg.Libmutton.SSHEntryRootPath, cfg.Libmutton.SSHAgeDirPath, nil
return sshClient, false, config.Libmutton.SSHIsWindows, config.Libmutton.SSHEntryRootPath, config.Libmutton.SSHAgeDirPath, nil
}
// GetSSHOutput runs a command over SSH and returns the output as a string.
@@ -171,18 +171,16 @@ func getLocalData() (map[string]int64, error) {
func getRealPathSFTP(vanityPath, serverEntryRoot string, serverIsWindows bool) string {
if !serverIsWindows {
return serverEntryRoot + vanityPath
} else {
return serverEntryRoot + strings.ReplaceAll(vanityPath, "/", "\\")
}
return serverEntryRoot + strings.ReplaceAll(vanityPath, "/", "\\")
}
// getRealPathSFTP formats the vanityPath to match the remote server's entry/age file directory and path separator.
func getRealAgePathSFTP(vanityPath, serverAgeDir string, serverIsWindows bool) string {
if !serverIsWindows {
return serverAgeDir + "/" + strings.ReplaceAll(vanityPath, "/", global.FSPath)
} else {
return serverAgeDir + "\\" + strings.ReplaceAll(vanityPath, "/", global.FSPath)
}
return serverAgeDir + "\\" + strings.ReplaceAll(vanityPath, "/", global.FSPath)
}
// sftpSync takes two slices of entries (one for downloads and one for uploads) and syncs them between the client and server using SFTP.
+2 -2
View File
@@ -68,7 +68,7 @@ end:
return nil
}
// RenameRemoteFromClient renames oldVanityPath to newVanityPath on
// RenameRemote renames oldVanityPath to newVanityPath on
// the local system and calls the server to perform the rename remotely and add the
// old target to the deletions list.
// It can safely be called in offline mode, as well, so this is the intended
@@ -120,7 +120,7 @@ end:
return nil
}
// AddFolderRemoteFromClient creates a new entry-containing directory
// AddFolderRemote creates a new entry-containing directory
// on the local system and calls the server to create the folder remotely.
// It can safely be called in offline mode, as well, so this is the
// intended interface for adding folders (AddFolderLocal should only be