Fix Turbopack module resolution for lzma and restore path imports

This commit is contained in:
openhands committed 2026-08-25 22:19:59 +02:00
1 parent a5044c80d7
commit e06596391e
35 files changed
+392 -333

No files matched your search

+10 -10
View File
@@ -1,6 +1,5 @@
import { existsSync, promises as fs } from "node:fs";
import os from "node:os";
import path from "node:path";
import { sql } from "drizzle-orm";
import { db } from "@/lib/db";
import {
@@ -16,6 +15,7 @@ import {
import { downloadFile } from "@/lib/services/import/core/download";
import { classifyCatalogItem, NO_ASSET_KINDS } from "@/lib/services/item-kind";
import { parseNitroBundle } from "@/lib/services/swf/nitro-builder";
import { getRuntimePath } from "@/lib/utils/runtime-path";
import { ensureDirectories } from "./furni-import";
import { convertSwfToNitro } from "./swf";
import { addSize32ToBundle } from "./swf/add-size32";
@@ -63,7 +63,7 @@ async function writeNitroToDirs(
for (const dir of dirs) {
try {
await fs.mkdir(dir, { recursive: true });
await fs.writeFile(path.join(dir, fileName), nitro);
await fs.writeFile(getRuntimePath(dir, fileName), nitro);
} catch (err) {
errors.push(`write .nitro to ${dir} failed: ${(err as Error).message}`);
}
@@ -77,12 +77,12 @@ async function copyNitroAcrossDirs(
fileName: string,
): Promise<string[]> {
const errors: string[] = [];
const src = path.join(srcDir, fileName);
const src = getRuntimePath(srcDir, fileName);
for (const dir of destDirs) {
if (dir === srcDir) continue;
try {
await fs.mkdir(dir, { recursive: true });
await fs.copyFile(src, path.join(dir, fileName));
await fs.copyFile(src, getRuntimePath(dir, fileName));
} catch (err) {
errors.push(`copy .nitro to ${dir} failed: ${(err as Error).message}`);
}
@@ -150,7 +150,7 @@ export async function repairMissingNitros(
const gamedataRoot = await getGamedataRoot();
if (gamedataRoot) {
const badgeFiles = await fs
.readdir(path.join(gamedataRoot, "album1584"))
.readdir(getRuntimePath(gamedataRoot, "album1584"))
.catch(() => [] as string[]);
albumBadgeSet = new Set(
badgeFiles.filter((f) => f.endsWith(".gif")).map((f) => f.slice(0, -4)),
@@ -210,7 +210,7 @@ export async function repairMissingNitros(
const fileName = `${classname}.nitro`;
const presentDirs = nitroDirs.filter((dir) =>
existsSync(path.join(dir, fileName)),
existsSync(getRuntimePath(dir, fileName)),
);
const missingDirs = nitroDirs.filter((dir) => !presentDirs.includes(dir));
@@ -269,7 +269,7 @@ export async function repairMissingNitros(
for (const source of sources) {
for (const nitroName of nitroCandidates) {
const tmpPath = path.join(
const tmpPath = getRuntimePath(
os.tmpdir(),
`.repair_nitro_${classname}_${Math.random().toString(36).slice(2, 8)}.nitro`,
);
@@ -469,7 +469,7 @@ export async function reconvertAllNitros(
const basesToProcess: string[] = [];
for (const base of existingBases) {
if (existsSync(path.join(targets.swfDir, `${base}.swf`))) {
if (existsSync(getRuntimePath(targets.swfDir, `${base}.swf`))) {
basesToProcess.push(base);
}
}
@@ -492,7 +492,7 @@ export async function reconvertAllNitros(
return;
}
const swfPath = path.join(targets.swfDir, `${base}.swf`);
const swfPath = getRuntimePath(targets.swfDir, `${base}.swf`);
let swf: Buffer;
try {
swf = await fs.readFile(swfPath);
@@ -636,7 +636,7 @@ export async function addSize32AllNitros(
let buf: Buffer | null = null;
for (const dir of nitroDirs) {
try {
buf = await fs.readFile(path.join(dir, fileName));
buf = await fs.readFile(getRuntimePath(dir, fileName));
break;
} catch {
/* try next dir */