fix: normalize path separators for cross-platform compatibility

- Ensure consistent cache keys across Windows and Unix systems
- Replace backslashes with forward slashes in relative paths
This commit is contained in:
Roo Code 2025-07-22 16:46:30 +00:00
parent a9b70e4e76
commit 743dc97ef4
2 changed files with 9 additions and 3 deletions

View file

@ -80,7 +80,9 @@ describe("CacheManager", () => {
relativePath = path.relative(homedir, mockWorkspacePath)
}
const compositeKey = `${workspaceName}::${relativePath}`
// Normalize path separators for consistency
const normalizedRelativePath = relativePath.replace(/\\/g, "/")
const compositeKey = `${workspaceName}::${normalizedRelativePath}`
const expectedHash = createHash("sha256").update(compositeKey).digest("hex")
expect(vscode.Uri.joinPath).toHaveBeenCalledWith(

View file

@ -56,10 +56,14 @@ export class CacheManager implements ICacheManager {
console.warn("Failed to get relative path from home directory:", error)
}
// Create a composite key using workspace name and relative path
// Normalize path separators to forward slashes for consistency across platforms
// This ensures the same cache key is generated regardless of the OS
const normalizedRelativePath = relativePath.replace(/\\/g, "/")
// Create a composite key using workspace name and normalized relative path
// This should be more stable across SSH sessions where the absolute path might change
// but the relative structure remains the same
const compositeKey = `${workspaceName}::${relativePath}`
const compositeKey = `${workspaceName}::${normalizedRelativePath}`
// Generate hash from the composite key
return createHash("sha256").update(compositeKey).digest("hex")