Merge d2edf67b28aeb4c5cae02576b5acf06ef63062a3 into 839eef0db269333870dc04cb79d0dd0c95e5a418

This commit is contained in:
albertony 2025-03-31 18:40:26 +00:00 committed by GitHub
commit 20112a7c89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -211,18 +211,19 @@ func createRootDirs(parentOSPath string, relativeDirOSPath string) (dataOSPath s
//
// Returns an os path for the data cache file.
func (c *Cache) createItemDir(name string) (string, error) {
parent := vfscommon.FindParent(name)
parentPath := c.toOSPath(parent)
err := createDir(parentPath)
if err != nil {
relativePath := toOSPath(name)
relativeDir := vfscommon.OSFindParent(relativePath)
// Ensure cache directories exists.
// Could skip this if relativeDir=="", since the cache root paths should
// always exist (ensured in New function), which would avoid unnecessary path
// operations and os.Stat, but by always doing it we get an extra failsafe...
if err := createDir(filepath.Join(c.root, relativeDir)); err != nil {
return "", fmt.Errorf("failed to create data cache item directory: %w", err)
}
parentPathMeta := c.toOSPathMeta(parent)
err = createDir(parentPathMeta)
if err != nil {
if err := createDir(filepath.Join(c.metaRoot, relativeDir)); err != nil {
return "", fmt.Errorf("failed to create metadata cache item directory: %w", err)
}
return c.toOSPath(name), nil
return filepath.Join(c.root, relativePath), nil
}
// getBackend gets a backend for a cache root dir