Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Commit

Permalink
解决rclone error问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkLeong committed Oct 13, 2021
1 parent b097d1b commit 29d67ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions webdav/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ type WalkFunc func(parent model.ListModel, info model.FileListModel, err error)
// Allowed values for depth are 0, 1 or infiniteDepth. For each visited node,
// walkFS calls walkFn. If a visited file system node is a directory and
// walkFn returns filepath.SkipDir, walkFS will skip traversal of this node.
func walkFS(ctx context.Context, fs FileSystem, depth int, parent model.ListModel, info model.FileListModel, walkFn WalkFunc, token, driver, userAgent string) error {
func walkFS(ctx context.Context, fs FileSystem, depth int, parent model.ListModel, info model.FileListModel, walkFn WalkFunc, token, driver, userAgent string, cheng int) error {
// This implementation is based on Walk's code in the standard path/filepath package.
err := walkFn(parent, info, nil)
if err != nil {
Expand All @@ -769,7 +769,6 @@ func walkFS(ctx context.Context, fs FileSystem, depth int, parent model.ListMode
if depth == 1 {
depth = 0
}

// Read directory names.

for _, fileInfo := range info.Items {
Expand All @@ -782,11 +781,12 @@ func walkFS(ctx context.Context, fs FileSystem, depth int, parent model.ListMode
return err
}
} else {
if fileInfo.Type == "folder" && !strings.Contains(userAgent, "RaiDrive") {
cheng += 1
if fileInfo.Type == "folder" && !strings.Contains(userAgent, "RaiDrive") && cheng < 2 {
info, _ := aliyun.GetList(token, driver, fileInfo.FileId)
walkFS(ctx, fs, depth, fileInfo, info, walkFn, token, driver, userAgent)
walkFS(ctx, fs, depth, fileInfo, info, walkFn, token, driver, userAgent, cheng)
} else {
err = walkFS(ctx, fs, depth, fileInfo, fileList, walkFn, token, driver, userAgent)
err = walkFS(ctx, fs, depth, fileInfo, fileList, walkFn, token, driver, userAgent, cheng)
if err != nil {
if fileInfo.Type != "folder" || err != filepath.SkipDir {
return err
Expand Down
7 changes: 5 additions & 2 deletions webdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,9 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status

walkFn := func(parent model.ListModel, info model.FileListModel, err error) error {
if reflect.DeepEqual(parent, model.ListModel{}) {
return nil
fmt.Print("dddd")
parent.Type = "folder"
parent.ParentFileId = "root"
}
if err != nil {
return err
Expand Down Expand Up @@ -873,7 +875,8 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
return mw.write(makePropstatResponse(href, pstats))
}
userAgent := r.Header.Get("User-Agent")
walkErr := walkFS(ctx, h.FileSystem, depth, fi, list, walkFn, h.Config.Token, h.Config.DriveId, userAgent)
cheng := 1
walkErr := walkFS(ctx, h.FileSystem, depth, fi, list, walkFn, h.Config.Token, h.Config.DriveId, userAgent, cheng)
closeErr := mw.close()
if walkErr != nil {
return http.StatusInternalServerError, walkErr
Expand Down

0 comments on commit 29d67ef

Please sign in to comment.