Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: deep target file paths for consistent snapshots #631

Closed
mrjoelkamp opened this issue Apr 10, 2024 · 0 comments · Fixed by #632
Closed

bug: deep target file paths for consistent snapshots #631

mrjoelkamp opened this issue Apr 10, 2024 · 0 comments · Fixed by #632

Comments

@mrjoelkamp
Copy link
Contributor

Issue

Deep target file paths, or file paths that are more than one subdirectory deep (e.g. <dir1>/<dir2>/file) fail to download due to the targetRemotePath being built wrong when using consistent snapshots.

Root Cause

Current state of the code uses strings.Cut() to parse the directory name from the file name. This works for target files that are only one directory deep (<subdir>/file.ext) because strings.Cut() splits the string on the first occurrence of the separator.

dirName, baseName, ok := strings.Cut(targetFilePath, "/")
if !ok {
// <hash>.<target-name>
targetRemotePath = fmt.Sprintf("%s.%s", hashes, dirName)
} else {
// <dir-prefix>/<hash>.<target-name>
targetRemotePath = fmt.Sprintf("%s/%s.%s", dirName, hashes, baseName)
}

For nested target file paths (<subdir1>/<subdir2>/file.ext) the targetRemotePath ends up being generated incorrectly since the first occurrence of / does not separate the directory from the file name.

When using consistent snapshots, this ends up making the path be <subdir1>/<hash>.<subdir2>/file.ext instead of <subdir1>/<subdir2>/<hash>.file.ext

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 a pull request may close this issue.

1 participant