mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
fix(upload): surface thumbnail/.torrent upload failures to the user
These optional-asset uploads are non-fatal, but failures were warn-only — the user got a silently-missing thumbnail or torrent with no signal. Both upload services now emit a 'warning' status at the point of failure and append a note to the final 'Published' status (downgraded to warning variant) listing what failed. Cloudflare-upload audit #5. Test: tests/services/s3-upload-optional-asset-failures.test.mjs. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
04ae0ec4e6
commit
3d6ffe997b
3 files changed
+156
-3
No files matched your search
@@ -949,6 +949,11 @@ class R2Service {
|
||||
region: effectiveSettings.region,
|
||||
});
|
||||
|
||||
// Track optional-asset failures so the user gets a visible signal instead
|
||||
// of a silently-missing thumbnail/torrent (Cloudflare-upload #5).
|
||||
let thumbnailFailed = false;
|
||||
let torrentFailed = false;
|
||||
|
||||
if (thumbnailFile) {
|
||||
this.setCloudflareUploadStatus("Uploading thumbnail...", "info");
|
||||
const thumbExt = thumbnailFile.name.split('.').pop() || 'jpg';
|
||||
@@ -970,6 +975,11 @@ class R2Service {
|
||||
}
|
||||
} catch (err) {
|
||||
userLogger.warn("Thumbnail upload failed, continuing with video...", err);
|
||||
thumbnailFailed = true;
|
||||
this.setCloudflareUploadStatus(
|
||||
"Thumbnail upload failed — publishing without it.",
|
||||
"warning"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1009,6 +1019,11 @@ class R2Service {
|
||||
}
|
||||
} catch (err) {
|
||||
userLogger.warn("Torrent metadata upload failed, continuing...", err);
|
||||
torrentFailed = true;
|
||||
this.setCloudflareUploadStatus(
|
||||
"Torrent upload failed — publishing URL-first without the .torrent.",
|
||||
"warning"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1107,9 +1122,15 @@ class R2Service {
|
||||
|
||||
publishOutcome = Boolean(published);
|
||||
if (publishOutcome) {
|
||||
const caveats = [];
|
||||
if (thumbnailFailed) caveats.push("thumbnail");
|
||||
if (torrentFailed) caveats.push("torrent");
|
||||
const suffix = caveats.length
|
||||
? ` (note: ${caveats.join(" & ")} upload failed)`
|
||||
: "";
|
||||
this.setCloudflareUploadStatus(
|
||||
`Published ${publicUrl}`,
|
||||
"success"
|
||||
`Published ${publicUrl}${suffix}`,
|
||||
caveats.length ? "warning" : "success"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user