Backfill missing nitros into the Gamedata bundle on import
After each single import, batch import and batch-regen, copy every .nitro file that is missing from /var/www/Gamedata/bundled/furniture so the emulator can render all imported furniture even when the mirror write was skipped. Reports the copied files in the API/SSE response.
This commit is contained in:
1 parent
99e77d9872
commit
bcd24bfca4
4 files changed
+77
-1
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
DEFAULT_FURNI_SWF_DIR,
|
||||
getFurniAssetDirs,
|
||||
getFurniAssetWriteTargets,
|
||||
getGamedataRoot,
|
||||
} from "@/lib/services/furni-asset-dirs";
|
||||
import {
|
||||
appendFurniEntry,
|
||||
@@ -346,6 +347,55 @@ export async function ensureFurniOwnership(): Promise<{ fixed: string[] }> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy every .nitro file that is missing from the emulator's Gamedata
|
||||
* bundle directory (/var/www/Gamedata/bundled/furniture) so all imported
|
||||
* furniture stays renderable in-game even when a mirror write was skipped.
|
||||
*/
|
||||
export async function syncNitrosToGamedataBundle(): Promise<{
|
||||
copied: string[];
|
||||
}> {
|
||||
if (process.platform === "win32") return { copied: [] };
|
||||
|
||||
const gamedataRoot = await getGamedataRoot();
|
||||
if (!gamedataRoot) return { copied: [] };
|
||||
|
||||
const targetDir = path.join(gamedataRoot, "bundled/furniture");
|
||||
const { nitroDir } = await getFurniAssetDirs();
|
||||
if (nitroDir === targetDir) return { copied: [] };
|
||||
if (!existsSync(nitroDir)) return { copied: [] };
|
||||
|
||||
try {
|
||||
await fs.mkdir(targetDir, { recursive: true });
|
||||
} catch {
|
||||
return { copied: [] };
|
||||
}
|
||||
|
||||
const copied: string[] = [];
|
||||
try {
|
||||
const entries = await fs.readdir(nitroDir);
|
||||
for (const entry of entries) {
|
||||
if (!entry.endsWith(".nitro")) continue;
|
||||
const dest = path.join(targetDir, entry);
|
||||
if (existsSync(dest)) continue;
|
||||
try {
|
||||
await fs.copyFile(path.join(nitroDir, entry), dest);
|
||||
copied.push(entry);
|
||||
} catch (err) {
|
||||
logger.warn("[import-furni] nitro sync copy failed", {
|
||||
entry,
|
||||
error: (err as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn("[import-furni] nitro sync scan failed", {
|
||||
error: (err as Error).message,
|
||||
});
|
||||
}
|
||||
return { copied };
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the next `catalog_items.id` and run the INSERT through a
|
||||
* process-level async mutex so concurrent imports in the same Node process
|
||||
|
||||
Reference in new issue
Block a user