Skip to content

Normalize local backend repository path with filepath.Join - #10

Open
anisurrahman75 wants to merge 1 commit into
masterfrom
fix-local-repo-double-slash
Open

Normalize local backend repository path with filepath.Join#10
anisurrahman75 wants to merge 1 commit into
masterfrom
fix-local-repo-double-slash

Conversation

@anisurrahman75

Copy link
Copy Markdown
Contributor

The ProviderLocal branch in setup.go built RESTIC_REPOSITORY with:

b.Envs[RESTIC_REPOSITORY] = fmt.Sprintf("%s/%s", b.Bucket, b.Directory)

This unconditionally inserts a / separator. When b.Directory already begins with a / (e.g. a repository directory: /pvc-local), the result contains a redundant double slash:

"/safe/data" + "/" + "/pvc-local/..." => "/safe/data//pvc-local/..."

The S3, Azure, and GCS branches already use filepath.Join, which normalizes and collapses redundant separators. This change makes the local branch consistent:

b.Envs[RESTIC_REPOSITORY] = filepath.Join(b.Bucket, b.Directory)

Impact

Cosmetic/robustness. POSIX and restic treat // and / as equivalent, so this was not a functional failure, but the double slash showed up verbatim in log lines and error messages (Is there a repository at the following location? /safe/data//...), which was confusing during debugging of local (PVC/NFS) backends.

Testing

  • go build ./..., go vet ./... clean.
  • go test ./... passes.

The ProviderLocal branch built RESTIC_REPOSITORY via fmt.Sprintf("%s/%s", b.Bucket, b.Directory),
which inserts a redundant separator when b.Directory already begins with '/'
(e.g. "/safe/data" + "/pvc-local" => "/safe/data//pvc-local"). The S3/Azure/GCS
branches already use filepath.Join, which normalizes the path; do the same for local
so the repository path is clean and consistent across providers.

Signed-off-by: Anisur Rahman <anisur@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant