Minor rename and logic adjustment

Only add to the hashes Set when guard is in place.
This commit is contained in:
awsr
2025-11-30 22:59:26 -08:00
parent b25cf56181
commit 35cd563c7d
+4 -4
View File
@@ -271,13 +271,13 @@ async function delayFetchThumb(fn) {
}
class GalleryFile extends HTMLElement {
#gallerySignal;
#signal;
constructor(folder, file, signal = undefined) {
super();
this.folder = folder;
this.name = file;
this.#gallerySignal = signal;
this.#signal = signal;
this.size = 0;
this.mtime = 0;
this.hash = undefined;
@@ -371,10 +371,10 @@ class GalleryFile extends HTMLElement {
img.src = `file=${this.src}`;
}
}
if (!this.#gallerySignal?.aborted) {
if (this.#signal && !this.#signal.aborted) {
// Guard against accessing external context from a stale initialization
galleryHashes.add(this.hash); // Add to hashes Set *after* any database operations
this.#gallerySignal = null; // Clean up reference to AbortSignal
this.#signal = null; // Clean up reference to AbortSignal
}
if (!ok) {
return;