"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
archive: fix a squashfs path to a single file listing its whole directory
Nick Craig-Wood67afe55a833c
diff --git a/backend/archive/archive_internal_test.go b/backend/archive/archive_internal_test.goindex 4d3cf2a0a..dea60615d 100644--- a/backend/archive/archive_internal_test.go+++ b/backend/archive/archive_internal_test.go@@ -175,6 +175,18 @@ func testArchive(t *testing.T, archiveName string, archiveFn func(t *testing.T,checkTree(ctx, "SubDir", t, ":archive:"+zipFile+"/"+subDir, filepath.Join(input, subDir), 0)// Now check a single file+ //+ // The filter below applies to both sides, so check first that the+ // archive exposes only that file without it+ Fsingle, err := cache.Get(ctx, ":archive:"+zipFile+"/"+aFile)+ require.NoError(t, err)+ entries, err := Fsingle.List(ctx, "")+ require.NoError(t, err)+ require.Len(t, entries, 1)+ _, err = Fsingle.List(ctx, subDir)+ assert.Equal(t, fs.ErrorDirNotFound, err)+ _, err = Fsingle.NewObject(ctx, subDir)+ assert.Equal(t, fs.ErrorObjectNotFound, err)fiCtx, fi := filter.AddConfig(ctx)require.NoError(t, fi.AddRule("+ "+aFile))require.NoError(t, fi.AddRule("- *"))diff --git a/backend/archive/squashfs/squashfs.go b/backend/archive/squashfs/squashfs.goindex 47868010e..240a949ae 100644--- a/backend/archive/squashfs/squashfs.go+++ b/backend/archive/squashfs/squashfs.go@@ -42,6 +42,7 @@ type Fs struct {prefix string // position for objectsprefixSlash string // position for objects with a slash onroot string // position to read from within the archive+ file string // remote of the single file root points at, if any}// recoverParsePanic converts a panic raised while parsing a squashfs image@@ -115,10 +116,13 @@ func New(ctx context.Context, wrappedFs fs.Fs, remote, prefix, root string) (_ f_, err := f.newObjectNative(native)if err == nil {// If it pointed to a file, find the directory above+ // and remember the file so that only it is listedf.root = path.Dir(f.root)if f.root == "." || f.root == "/" {f.root = ""}+ f.file = f.prefixSlash + path.Base(native)+ singleObject = true}}}@@ -150,7 +154,9 @@ func (f *Fs) Name() string {// Root of the remote (as passed into NewFs)func (f *Fs) Root() string {- return f.root+ // Include the file so the fs cache can tell this Fs apart from+ // the one for the directory containing it+ return path.Join(f.root, f.file)}// Features returns the optional features of this Fs@@ -227,6 +233,10 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err edefer log.Trace(f, "dir=%q", dir)("entries=%v, err=%v", &entries, &err)defer recoverParsePanic(&err)+ if f.file != "" && dir != "" {+ return nil, fs.ErrorDirNotFound+ }+nativeDir, err := f.toNative(dir)if err != nil {return nil, err@@ -265,6 +275,9 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err efs.Debugf(item.Name(), "FIXME Not regular file - skipping")continue}+ if f.file != "" && entry.Remote() != f.file {+ continue+ }entries = append(entries, entry)}@@ -316,6 +329,9 @@ func (f *Fs) newObjectNative(nativePath string) (o fs.Object, err error) {func (f *Fs) NewObject(ctx context.Context, remote string) (o fs.Object, err error) {defer log.Trace(f, "remote=%q", remote)("obj=%v, err=%v", &o, &err)+ if f.file != "" && remote != f.file {+ return nil, fs.ErrorObjectNotFound+ }nativePath, err := f.toNative(remote)if err != nil {return nil, err