mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
Refactor image fallback logic in RoomService: update comments for clarity and improve image resolution checks for S3 storage.
This commit is contained in:
@@ -224,14 +224,12 @@ public class RoomService(DorkNetDbContext db)
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
// The watch fetches each tile thumbnail by ImageName; a name
|
// The watch fetches each tile thumbnail by ImageName; a name
|
||||||
// that doesn't resolve to a file on disk (or in S3) lands on
|
// that doesn't resolve in S3/disk lands on the transparent-PNG
|
||||||
// the transparent-PNG fallback, which the watch's image pipe
|
// fallback, which the watch renders as the placeholder image.
|
||||||
// renders as the red "?" placeholder. For each seeded row pick
|
// In production, RRO thumbnails live in S3 under BlobRouter's
|
||||||
// the best ImageName in this priority order: (1) the hash
|
// image/<blob-name> keys, so do NOT require the mapped blob
|
||||||
// filename from room_images.json, (2) the original
|
// filename to exist on local disk before using it. Local disk
|
||||||
// image_<slug>.png placeholder, (3) image_RecCenter.png as a
|
// is only a fallback for rooms with no blob-name mapping.
|
||||||
// guaranteed-present fallback. Anything we pick must exist as
|
|
||||||
// a file under data/images so the disk hit path serves it.
|
|
||||||
const string ultimateFallback = "image_RecCenter.png";
|
const string ultimateFallback = "image_RecCenter.png";
|
||||||
var imagesDir = Path.Combine(AppContext.BaseDirectory, "data", "images");
|
var imagesDir = Path.Combine(AppContext.BaseDirectory, "data", "images");
|
||||||
bool OnDisk(string name) =>
|
bool OnDisk(string name) =>
|
||||||
@@ -241,7 +239,7 @@ public class RoomService(DorkNetDbContext db)
|
|||||||
foreach (var r in rows)
|
foreach (var r in rows)
|
||||||
{
|
{
|
||||||
string preferred;
|
string preferred;
|
||||||
if (RoomImagesByName.TryGetValue(r.Name, out var realImg) && OnDisk(realImg))
|
if (RoomImagesByName.TryGetValue(r.Name, out var realImg) && !string.IsNullOrWhiteSpace(realImg))
|
||||||
preferred = realImg;
|
preferred = realImg;
|
||||||
else if (OnDisk($"image_{r.Name}.png"))
|
else if (OnDisk($"image_{r.Name}.png"))
|
||||||
preferred = $"image_{r.Name}.png";
|
preferred = $"image_{r.Name}.png";
|
||||||
|
|||||||
Reference in New Issue
Block a user