mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
refactor: use strings.Builder to improve performance
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
This commit is contained in:
@@ -4,6 +4,7 @@ package cryptdecode
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rclone/rclone/backend/crypt"
|
||||
"github.com/rclone/rclone/cmd"
|
||||
@@ -67,32 +68,32 @@ command. See the documentation on the [crypt](/crypt/) overlay for more info.`,
|
||||
|
||||
// cryptDecode returns the unencrypted file name
|
||||
func cryptDecode(cipher *crypt.Cipher, args []string) error {
|
||||
output := ""
|
||||
var output strings.Builder
|
||||
|
||||
for _, encryptedFileName := range args {
|
||||
fileName, err := cipher.DecryptFileName(encryptedFileName)
|
||||
if err != nil {
|
||||
output += fmt.Sprintln(encryptedFileName, "\t", "Failed to decrypt")
|
||||
output.WriteString(fmt.Sprintln(encryptedFileName, "\t", "Failed to decrypt"))
|
||||
} else {
|
||||
output += fmt.Sprintln(encryptedFileName, "\t", fileName)
|
||||
output.WriteString(fmt.Sprintln(encryptedFileName, "\t", fileName))
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Print(output)
|
||||
fmt.Print(output.String())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// cryptEncode returns the encrypted file name
|
||||
func cryptEncode(cipher *crypt.Cipher, args []string) error {
|
||||
output := ""
|
||||
var output strings.Builder
|
||||
|
||||
for _, fileName := range args {
|
||||
encryptedFileName := cipher.EncryptFileName(fileName)
|
||||
output += fmt.Sprintln(fileName, "\t", encryptedFileName)
|
||||
output.WriteString(fmt.Sprintln(fileName, "\t", encryptedFileName))
|
||||
}
|
||||
|
||||
fmt.Print(output)
|
||||
fmt.Print(output.String())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user