Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

cache: fix nil pointer deref when using lsjson on cached directory

Nick Craig-Woodffd11662babc
diff --git a/backend/cache/directory.go b/backend/cache/directory.go
index 658dbda72..863612758 100644
--- a/backend/cache/directory.go
+++ b/backend/cache/directory.go
@@ -12,7 +12,7 @@ import (
// Directory is a generic dir that stores basic information about it
type Directory struct {
- fs.Directory `json:"-"`
+ Directory fs.Directory `json:"-"` // can be nil
CacheFs *Fs `json:"-"` // cache fs
Name string `json:"name"` // name of the directory
@@ -125,6 +125,14 @@ func (d *Directory) Items() int64 {
return d.CacheItems
}
+// ID returns the ID of the cached directory if known
+func (d *Directory) ID() string {
+ if d.Directory == nil {
+ return ""
+ }
+ return d.Directory.ID()
+}
+
var (
_ fs.Directory = (*Directory)(nil)
)