Skip to content

Commit

Permalink
vfs: fix cache encoding with special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
URenko committed Apr 22, 2024
1 parent 97fe749 commit 1863b81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ func (f *Fs) localPath(name string) string {
return filepath.Join(f.root, filepath.FromSlash(f.opt.Enc.FromStandardPath(name)))
}

// LocalToStandardPath coverts the file name in the local filesystem to StandardPath with the user specified encoding
func (f *Fs) LocalToStandardPath(name string) string {
return f.opt.Enc.ToStandardPath(filepath.ToSlash(name))
}

// Put the Object to the local filesystem
func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error) {
// Temporary Object under construction - info filled in by Update()
Expand Down
3 changes: 2 additions & 1 deletion vfs/vfscache/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sync"
"time"

"github.com/rclone/rclone/backend/local"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/fserrors"
"github.com/rclone/rclone/fs/operations"
Expand Down Expand Up @@ -581,7 +582,7 @@ func (item *Item) _store(ctx context.Context, storeFn StoreFn) (err error) {
// defer log.Trace(item.name, "item=%p", item)("err=%v", &err)

// Transfer the temp file to the remote
cacheObj, err := item.c.fcache.NewObject(ctx, item.name)
cacheObj, err := item.c.fcache.NewObject(ctx, item.c.fcache.(*local.Fs).LocalToStandardPath(toOSPath(item.name)))
if err != nil && err != fs.ErrorObjectNotFound {
return fmt.Errorf("vfs cache: failed to find cache file: %w", err)
}
Expand Down

0 comments on commit 1863b81

Please sign in to comment.