@lacrous/omnicloud 0.2.12 → 0.2.14
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/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/server/index.js +24 -9
package/dist/index.cjs
CHANGED
|
@@ -1472,7 +1472,7 @@ var noopActivityRecorder = {
|
|
|
1472
1472
|
// ../core/src/utils/filename.ts
|
|
1473
1473
|
function sanitizeFileName(name) {
|
|
1474
1474
|
const base = name.split(/[/\\]/).pop() ?? name;
|
|
1475
|
-
const cleaned = base.replace(/[\u0000-\u001f\u007f]/g, "").replace(/[<>:"|?*]/g, "_").trim();
|
|
1475
|
+
const cleaned = base.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").replace(/[\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "").replace(/[<>:"|?*]/g, "_").trim();
|
|
1476
1476
|
if (!cleaned || cleaned === "." || cleaned === "..") return "";
|
|
1477
1477
|
return cleaned.slice(0, 255);
|
|
1478
1478
|
}
|
|
@@ -1542,6 +1542,7 @@ var FileService = class {
|
|
|
1542
1542
|
const record = await this.performUpload(userId, input, {
|
|
1543
1543
|
onStored: async (stored) => {
|
|
1544
1544
|
await operations.update(op.id, { telegramMessageId: Number(stored.messageId) });
|
|
1545
|
+
await operations.claim(op.id, "UPLOADING", "COMMITTING");
|
|
1545
1546
|
}
|
|
1546
1547
|
});
|
|
1547
1548
|
await operations.update(op.id, { status: "COMPLETED", fileId: record.id });
|
|
@@ -1582,13 +1583,27 @@ var FileService = class {
|
|
|
1582
1583
|
const mimeType = mimeFromFilename(name);
|
|
1583
1584
|
const size = op.size ?? input.spooled?.size ?? input.data?.byteLength ?? 0;
|
|
1584
1585
|
const sha256 = op.sha256 ?? input.spooled?.sha256 ?? sha256Hex(input.data ?? Buffer.alloc(0));
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1586
|
+
const claimed = await operations.claim(op.id, "UPLOADING", "COMMITTING");
|
|
1587
|
+
if (!claimed) {
|
|
1588
|
+
const current = await operations.findByOperationId(userId, op.operationId);
|
|
1589
|
+
if (current?.status === "COMPLETED" && current.fileId) {
|
|
1590
|
+
return this.get(userId, current.fileId);
|
|
1591
|
+
}
|
|
1592
|
+
throw new ConflictError("This upload is being committed by another request. Retry shortly.");
|
|
1593
|
+
}
|
|
1594
|
+
let record;
|
|
1595
|
+
try {
|
|
1596
|
+
record = await this.commitRecord(userId, input, {
|
|
1597
|
+
name,
|
|
1598
|
+
mimeType,
|
|
1599
|
+
size,
|
|
1600
|
+
sha256,
|
|
1601
|
+
telegramMessageId: op.telegramMessageId
|
|
1602
|
+
});
|
|
1603
|
+
} catch (error) {
|
|
1604
|
+
await operations.claim(op.id, "COMMITTING", "UPLOADING");
|
|
1605
|
+
throw error;
|
|
1606
|
+
}
|
|
1592
1607
|
await operations.update(op.id, { status: "COMPLETED", fileId: record.id });
|
|
1593
1608
|
return record;
|
|
1594
1609
|
}
|