From 2de0da87fa9e41155163580cce63f1c7489009ac Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Tue, 13 Sep 2022 18:34:04 +0800 Subject: [PATCH] fix: infinite loop if new multi-level folder (close #1661) --- drivers/quark/driver.go | 4 ++++ internal/op/fs.go | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/quark/driver.go b/drivers/quark/driver.go index abae1707322..59a3dc1dac6 100644 --- a/drivers/quark/driver.go +++ b/drivers/quark/driver.go @@ -8,6 +8,7 @@ import ( "io" "net/http" "os" + "time" "github.com/alist-org/alist/v3/drivers/base" "github.com/alist-org/alist/v3/internal/driver" @@ -90,6 +91,9 @@ func (d *Quark) MakeDir(ctx context.Context, parentDir model.Obj, dirName string _, err := d.request("/file", http.MethodPost, func(req *resty.Request) { req.SetBody(data) }, nil) + if err == nil { + time.Sleep(time.Second) + } return err } diff --git a/internal/op/fs.go b/internal/op/fs.go index 4e772b47777..cf04cca05bd 100644 --- a/internal/op/fs.go +++ b/internal/op/fs.go @@ -181,6 +181,7 @@ func MakeDir(ctx context.Context, storage driver.Driver, path string) error { if storage.Config().CheckStatus && storage.GetStorage().Status != WORK { return errors.Errorf("storage not init: %s", storage.GetStorage().Status) } + path = utils.StandardizePath(path) // check if dir exists f, err := Get(ctx, storage, path) if err != nil { @@ -195,7 +196,11 @@ func MakeDir(ctx context.Context, storage driver.Driver, path string) error { if err != nil { return errors.WithMessagef(err, "failed to get parent dir [%s]", parentPath) } - return errors.WithStack(storage.MakeDir(ctx, parentDir, dirName)) + err = storage.MakeDir(ctx, parentDir, dirName) + if err == nil { + ClearCache(storage, parentPath) + } + return errors.WithStack(err) } else { return errors.WithMessage(err, "failed to check if dir exists") }