mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 15:41:20 +02:00
refactor: Update rclone connection logic for provider handling
- Consolidated provider handling for Hetzner and S3-compatible providers (Minio, Wasabi) to improve clarity and maintainability. - Adjusted configuration arguments to use the primary provider name consistently across different cases. - Enhanced endpoint handling for Minio and B2 providers, ensuring correct parameter usage in rclone configuration generation.
This commit is contained in:
@@ -90,12 +90,20 @@ func TestRcloneConnection(config db.TransferConfig, providerType string, dbInsta
|
|||||||
rclonePath = "rclone"
|
rclonePath = "rclone"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
primaryProvider := provider
|
||||||
|
|
||||||
|
// Convert hetzner to sftp
|
||||||
if provider == "hetzner" {
|
if provider == "hetzner" {
|
||||||
provider = "sftp"
|
primaryProvider = "sftp"
|
||||||
|
}
|
||||||
|
|
||||||
|
// S3 compatible providers
|
||||||
|
if provider == "minio" || provider == "wasabi" {
|
||||||
|
primaryProvider = "s3"
|
||||||
}
|
}
|
||||||
|
|
||||||
createArgs := []string{
|
createArgs := []string{
|
||||||
"config", "create", remoteName, provider,
|
"config", "create", remoteName, primaryProvider,
|
||||||
"--config", tempConfigPath,
|
"--config", tempConfigPath,
|
||||||
"--non-interactive",
|
"--non-interactive",
|
||||||
"--log-level", "DEBUG",
|
"--log-level", "DEBUG",
|
||||||
@@ -145,25 +153,9 @@ func TestRcloneConnection(config db.TransferConfig, providerType string, dbInsta
|
|||||||
if region != "" {
|
if region != "" {
|
||||||
createArgs = append(createArgs, "region", region)
|
createArgs = append(createArgs, "region", region)
|
||||||
}
|
}
|
||||||
endpointValue := endpoint
|
|
||||||
if endpointValue == "" {
|
|
||||||
endpointValue = "s3.wasabisys.com"
|
|
||||||
}
|
|
||||||
createArgs = append(createArgs, "endpoint", endpointValue)
|
|
||||||
case "b2":
|
|
||||||
createArgs = append(createArgs, "provider", "B2", "env_auth", "false")
|
|
||||||
if accessKey != "" {
|
|
||||||
createArgs = append(createArgs, "account", accessKey)
|
|
||||||
}
|
|
||||||
if secretKey != "" {
|
|
||||||
createArgs = append(createArgs, "key", secretKey)
|
|
||||||
}
|
|
||||||
if endpoint != "" {
|
if endpoint != "" {
|
||||||
createArgs = append(createArgs, "endpoint", endpoint)
|
createArgs = append(createArgs, "endpoint", endpoint)
|
||||||
}
|
}
|
||||||
if region != "" {
|
|
||||||
createArgs = append(createArgs, "region", region)
|
|
||||||
}
|
|
||||||
case "minio":
|
case "minio":
|
||||||
createArgs = append(createArgs, "provider", "Minio", "env_auth", "false")
|
createArgs = append(createArgs, "provider", "Minio", "env_auth", "false")
|
||||||
if accessKey != "" {
|
if accessKey != "" {
|
||||||
@@ -172,6 +164,20 @@ func TestRcloneConnection(config db.TransferConfig, providerType string, dbInsta
|
|||||||
if secretKey != "" {
|
if secretKey != "" {
|
||||||
createArgs = append(createArgs, "secret_access_key", secretKey)
|
createArgs = append(createArgs, "secret_access_key", secretKey)
|
||||||
}
|
}
|
||||||
|
if region != "" {
|
||||||
|
createArgs = append(createArgs, "region", region)
|
||||||
|
}
|
||||||
|
if endpoint != "" {
|
||||||
|
createArgs = append(createArgs, "endpoint", endpoint)
|
||||||
|
}
|
||||||
|
case "b2":
|
||||||
|
createArgs = append(createArgs, "provider", "B2", "env_auth", "false")
|
||||||
|
if accessKey != "" {
|
||||||
|
createArgs = append(createArgs, "account", accessKey)
|
||||||
|
}
|
||||||
|
if secretKey != "" {
|
||||||
|
createArgs = append(createArgs, "key", secretKey)
|
||||||
|
}
|
||||||
if endpoint != "" {
|
if endpoint != "" {
|
||||||
createArgs = append(createArgs, "endpoint", endpoint)
|
createArgs = append(createArgs, "endpoint", endpoint)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user