From c8ceb209fccf917ceaea44e846bfe7870067a1ed Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 26 May 2026 09:46:22 +0100 Subject: [PATCH] drime: fix server-side copy and move failing with Cloudflare 520 error The drime origin returns a malformed response (reported by Cloudflare as a 520 error) for a literal PUT request to the file-entries update endpoint, which broke renaming, and so server-side copy and move. Use a POST with the X-HTTP-Method-Override: PUT header instead - the API routes this to the same handler and it works reliably. Also retry Cloudflare 520-524 errors which may occur transiently. --- backend/drime/drime.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/drime/drime.go b/backend/drime/drime.go index 4281bb853..22d63487f 100644 --- a/backend/drime/drime.go +++ b/backend/drime/drime.go @@ -282,6 +282,11 @@ var retryErrorCodes = []int{ 503, // Service Unavailable 504, // Gateway Timeout 509, // Bandwidth Limit Exceeded + 520, // Cloudflare: Web server returns an unknown error + 521, // Cloudflare: Web server is down + 522, // Cloudflare: Connection timed out + 523, // Cloudflare: Origin is unreachable + 524, // Cloudflare: A timeout occurred } // shouldRetry returns a boolean as to whether this resp and err @@ -848,10 +853,16 @@ func (f *Fs) patch(ctx context.Context, id, attribute string, value string) (ite Name: value, } var result api.UpdateItemResponse + // The drime origin returns a malformed response (seen by Cloudflare as + // a 520) for a literal PUT to this endpoint, so use a POST with Laravel + // method spoofing instead - the API routes it to the same handler. opts := rest.Opts{ - Method: "PUT", + Method: "POST", Path: "/file-entries/" + id, Parameters: url.Values{}, + ExtraHeaders: map[string]string{ + "X-HTTP-Method-Override": "PUT", + }, } if f.opt.WorkspaceID != "" { opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)