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 23, 2024
1 parent aaaf6fb commit 5468395
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions lib/encoder/internal/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func main() {
fatalW(fd.WriteString(" "))("Write:")
}
in, out := buildTestString(
[]mapping{getMapping(m.mask)}, // pick
[]mapping{getMapping(encoder.EncodeZero)}, // quote
[]mapping{getMapping(m.mask)}, // pick
[]mapping{getMapping(encoder.EncodeZero)}, // quote
printables, fullwidthPrintables, encodables, encoded, greek) // fill
fatalW(fmt.Fprintf(fd, `{ // %d
mask: %s,
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 5468395

Please sign in to comment.