Centralize path-safe root joins and atomic file operations
This commit is contained in:
@@ -309,11 +309,7 @@ func deriveManifestRelativePath(previousManifest *manifest.Manifest, localPath s
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
rel, err := filepath.Rel(sessionRoot, trimmed)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
normalized, err := pathsafe.NormalizeRelativeDestination(filepath.ToSlash(rel))
|
||||
normalized, err := pathsafe.SlashRelativeFromRoot(sessionRoot, trimmed)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
@@ -375,11 +371,7 @@ func relativeToSession(paths artifacts.SessionPaths, localPath string) (string,
|
||||
if strings.TrimSpace(root) == "" {
|
||||
return "", fmt.Errorf("session root is required")
|
||||
}
|
||||
rel, err := filepath.Rel(root, filepath.Clean(localPath))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("resolve previous-cache relative path: %w", err)
|
||||
}
|
||||
normalized, err := pathsafe.NormalizeRelativeDestination(filepath.ToSlash(rel))
|
||||
normalized, err := pathsafe.SlashRelativeFromRoot(root, localPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("resolve previous-cache relative path: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user