omo-web 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +31 -6
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -13277,7 +13277,7 @@ ${source.nativeSessionId}`;
|
|
|
13277
13277
|
|
|
13278
13278
|
// src/send-file.ts
|
|
13279
13279
|
import { constants as constants6 } from "fs";
|
|
13280
|
-
import { lstat as lstat8, mkdir as mkdir2, open as open7, readdir as readdir4, realpath as realpath8, rename as rename2, unlink as unlink3, writeFile as writeFile3 } from "fs/promises";
|
|
13280
|
+
import { lstat as lstat8, mkdir as mkdir2, open as open7, readFile as readFile3, readdir as readdir4, realpath as realpath8, rename as rename2, unlink as unlink3, writeFile as writeFile3 } from "fs/promises";
|
|
13281
13281
|
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute2, join as join8, relative, resolve as resolve6, sep as sep3 } from "path";
|
|
13282
13282
|
import { createHash as createHash3, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
13283
13283
|
import { Database } from "bun:sqlite";
|
|
@@ -13399,7 +13399,18 @@ class AttachmentStore {
|
|
|
13399
13399
|
}
|
|
13400
13400
|
const lock = new Database(lockPath);
|
|
13401
13401
|
try {
|
|
13402
|
-
lock.exec("
|
|
13402
|
+
lock.exec("PRAGMA busy_timeout = 300");
|
|
13403
|
+
try {
|
|
13404
|
+
lock.exec("BEGIN EXCLUSIVE");
|
|
13405
|
+
} catch (error) {
|
|
13406
|
+
if (!(error instanceof Error && ("code" in error) && error.code === "SQLITE_BUSY"))
|
|
13407
|
+
throw error;
|
|
13408
|
+
let pid = "";
|
|
13409
|
+
try {
|
|
13410
|
+
pid = (await readFile3(join8(dirname5(this.#directory), "omo-web.pid"), "utf8")).trim().match(/^\d+$/)?.[0] ?? "";
|
|
13411
|
+
} catch {}
|
|
13412
|
+
throw new WebError(409, "data_dir_in_use", `\u6570\u636E\u76EE\u5F55 ${dirname5(this.#directory)} \u5DF2\u88AB\u53E6\u4E00\u4E2A OmO Web \u8FDB\u7A0B\u5360\u7528${pid ? `\uFF08PID ${pid}\uFF09` : ""}\u3002\u8BF7\u5148\u505C\u6B62\u5DF2\u5728\u8FD0\u884C\u7684 omo-web serve\uFF0C\u518D\u91CD\u65B0\u542F\u52A8\uFF1B\u5982\u9700\u5E76\u884C\u8FD0\u884C\uFF0C\u53EF\u7528 OMO_WEB_DATA \u6307\u5B9A\u522B\u7684\u76EE\u5F55\u3002\u53E6\u4E00\u4E2A\u8FDB\u7A0B\u5DF2\u5728\u8FD0\u884C\u7684\u8BDD\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6253\u5F00\u5B83\u8F93\u51FA\u7684\u7F51\u5740\u3002`);
|
|
13413
|
+
}
|
|
13403
13414
|
this.#used = 0n;
|
|
13404
13415
|
for (const entry of await readdir4(this.#directory, { withFileTypes: true })) {
|
|
13405
13416
|
if (!entry.isFile())
|
|
@@ -13411,6 +13422,10 @@ class AttachmentStore {
|
|
|
13411
13422
|
this.#identity = { dev: directory.dev, ino: directory.ino };
|
|
13412
13423
|
await this.#verifyDirectory();
|
|
13413
13424
|
this.#lock = lock;
|
|
13425
|
+
try {
|
|
13426
|
+
await writeFile3(join8(dirname5(this.#directory), "omo-web.pid"), `${process.pid}
|
|
13427
|
+
`, { mode: 384 });
|
|
13428
|
+
} catch {}
|
|
13414
13429
|
} catch (error) {
|
|
13415
13430
|
lock.close();
|
|
13416
13431
|
throw error;
|
|
@@ -13421,6 +13436,11 @@ class AttachmentStore {
|
|
|
13421
13436
|
this.#lock?.close();
|
|
13422
13437
|
this.#lock = undefined;
|
|
13423
13438
|
this.#identity = undefined;
|
|
13439
|
+
const pidPath = join8(dirname5(this.#directory), "omo-web.pid");
|
|
13440
|
+
try {
|
|
13441
|
+
if ((await readFile3(pidPath, "utf8")).trim() === String(process.pid))
|
|
13442
|
+
await unlink3(pidPath);
|
|
13443
|
+
} catch {}
|
|
13424
13444
|
}
|
|
13425
13445
|
async#verifyDirectory() {
|
|
13426
13446
|
if (!this.#identity)
|
|
@@ -15336,10 +15356,15 @@ var app = await startApp({
|
|
|
15336
15356
|
"in-process"
|
|
15337
15357
|
]
|
|
15338
15358
|
}).catch((error) => {
|
|
15339
|
-
if (
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15359
|
+
if (error instanceof WebAccessConfigError) {
|
|
15360
|
+
console.error(`OmO Web config: ${error.message}`);
|
|
15361
|
+
process.exit(1);
|
|
15362
|
+
}
|
|
15363
|
+
if (error instanceof WebError) {
|
|
15364
|
+
console.error(cliTr(`OmO Web \u65E0\u6CD5\u542F\u52A8\uFF1A${error.message}`, `OmO Web cannot start: ${error.message}`));
|
|
15365
|
+
process.exit(1);
|
|
15366
|
+
}
|
|
15367
|
+
throw error;
|
|
15343
15368
|
});
|
|
15344
15369
|
if (app.unprotected)
|
|
15345
15370
|
console.warn(cliTr("\u8B66\u544A\uFF1A\u975E\u672C\u673A\u5165\u53E3\u672A\u8BBE\u5BC6\u7801\u3002\u80FD\u8BBF\u95EE\u6B64\u5730\u5740\u7684\u4EBA\u90FD\u80FD\u8BFB\u53D6\u4F1A\u8BDD\u5E76\u901A\u8FC7 OmO \u64CD\u4F5C\u672C\u673A\u3002\u4EC5\u5728\u53D7\u9650\u79C1\u7F51\u6216 VPN \u5185\u4F7F\u7528\u3002", "Warning: remote access without a password. Anyone who can reach this address can read sessions and run tools through OmO. Use only on a restricted private network or VPN."));
|
package/package.json
CHANGED