Skip to content

Commit

Permalink
fix: infinite loop if new multi-level folder (close #1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 13, 2022
1 parent 53e08e7 commit 2de0da8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions drivers/quark/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 6 additions & 1 deletion internal/op/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
}
Expand Down

0 comments on commit 2de0da8

Please sign in to comment.