Commit 33e3f500 authored by WorldTeacher's avatar WorldTeacher
Browse files

fix(sync): fallback to individual upload on 403 Forbidden

The batch endpoint returns 403 Forbidden when it's not available or
accessible on the server. Previously only 404 errors triggered fallback
to individual uploads, causing all batches to fail with 403.

Now treats 403 the same as 404:
- Automatically falls back to individual session upload
- Individual uploads use the standard endpoint which works
- Prevents mass failures when batch endpoint is unavailable

This fixes the issue where 1,208 sessions failed due to batch 403 errors
while individual uploads would have succeeded.

Log output will now show:
'Batch returned 403, falling back to individual upload for batch X'
parent 59f37ede
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2397,10 +2397,10 @@ function BookloreSync:_uploadSessionsWithBatching(book_id, book_type, sessions)
                synced_count = synced_count + 1
            end
            self:logInfo("BookloreSync: Batch", batch_num, "of", batch_count, "uploaded successfully (" .. (end_idx - start_idx + 1) .. " sessions)")
        elseif code == 404 then
            -- Server doesn't have batch endpoint OR book not found
        elseif code == 404 or code == 403 then
            -- Server doesn't have batch endpoint (404/403) OR book not found (404)
            -- Fallback to individual upload to determine which
            self:logWarn("BookloreSync: Batch returned 404, falling back to individual upload for batch", batch_num)
            self:logWarn("BookloreSync: Batch returned", code, "falling back to individual upload for batch", batch_num)
            
            for i = start_idx, end_idx do
                local session = sessions[i]