From 64fc3d05ae4aace7cbd7c6de82498f556b49ff2d Mon Sep 17 00:00:00 2001 From: wiserain Date: Fri, 4 Jul 2025 15:27:29 +0900 Subject: [PATCH] pikpak: improve error handling for missing links and unrecoverable 500s This commit improves error handling in two specific scenarios: * Missing Download Links: A 5-second delay is introduced when a download link is missing, as low-level retries aren't enough. Empirically, it takes about 30s-1m for the link to become available. This resolves failed integration tests: backend: TestIntegration/FsMkdir/FsPutFiles/ ObjectUpdate, vfs: TestFileReadAtNonZeroLength * Unrecoverable 500 Errors: The shouldRetry method is updated to skip retries for 500 errors from "idx.shub.mypikpak.com" indicating "no record for gcid." These errors are non-recoverable, so retrying is futile. --- backend/pikpak/helper.go | 1 + backend/pikpak/pikpak.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/backend/pikpak/helper.go b/backend/pikpak/helper.go index a5ff0ca00..9bc8ea041 100644 --- a/backend/pikpak/helper.go +++ b/backend/pikpak/helper.go @@ -155,6 +155,7 @@ func (f *Fs) getFile(ctx context.Context, ID string) (info *api.File, err error) err = f.pacer.Call(func() (bool, error) { resp, err = f.rst.CallJSON(ctx, &opts, nil, &info) if err == nil && !info.Links.ApplicationOctetStream.Valid() { + time.Sleep(5 * time.Second) return true, errors.New("no link") } return f.shouldRetry(ctx, resp, err) diff --git a/backend/pikpak/pikpak.go b/backend/pikpak/pikpak.go index bda10993a..21580fd13 100644 --- a/backend/pikpak/pikpak.go +++ b/backend/pikpak/pikpak.go @@ -467,6 +467,11 @@ func (f *Fs) shouldRetry(ctx context.Context, resp *http.Response, err error) (b // when a zero-byte file was uploaded with an invalid captcha token f.rst.captcha.Invalidate() return true, err + } else if strings.Contains(apiErr.Reason, "idx.shub.mypikpak.com") && apiErr.Code == 500 { + // internal server error: Post "http://idx.shub.mypikpak.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers) + // This typically happens when trying to retrieve a gcid for which no record exists. + // No retry is needed in this case. + return false, err } }