From c10eb47bb6681e0e4cc6d40eaf8dcdc59d6b70d0 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 18 Jul 2026 16:19:48 +0100 Subject: [PATCH] archive: fix squashfs listings failing with invalid argument after update The go-diskfs library now requires io/fs.ValidPath style paths (no leading slash, "." for the root) so convert paths at the library boundary. This fixes listing failures and the resulting test hangs after the update to go-diskfs v1.9.3. --- backend/archive/squashfs/squashfs.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/archive/squashfs/squashfs.go b/backend/archive/squashfs/squashfs.go index 0d6425862..d04082275 100644 --- a/backend/archive/squashfs/squashfs.go +++ b/backend/archive/squashfs/squashfs.go @@ -156,6 +156,17 @@ func (f *Fs) toNative(remote string) (string, error) { return native, nil } +// This turns a native path with a leading / into a path suitable for +// the squashfs library which requires io/fs.ValidPath paths with no +// leading / and "." for the root directory. +func toIOFS(native string) string { + native = strings.Trim(native, "/") + if native == "" { + return "." + } + return native +} + // Turn a (nativeDir, leaf) into a remote func (f *Fs) fromNative(nativeDir string, leaf string) string { // fs.Debugf(nil, "nativeDir = %q, leaf = %q, root=%q", nativeDir, leaf, f.root) @@ -196,7 +207,7 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e return nil, err } - items, err := f.sqfs.ReadDir(nativeDir) + items, err := f.sqfs.ReadDir(toIOFS(nativeDir)) if err != nil { return nil, fmt.Errorf("read squashfs: couldn't read directory: %w", err) } @@ -238,7 +249,7 @@ func (f *Fs) newObjectNative(nativePath string) (o fs.Object, err error) { leaf = strings.Trim(leaf, "/") // FIXME need to detect directory not found - fis, err := f.sqfs.ReadDir(dir) + fis, err := f.sqfs.ReadDir(toIOFS(dir)) if err != nil { return nil, fs.ErrorObjectNotFound