@lacrous/omnicloud 0.2.13 → 0.2.15
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 +22 -7
- 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 +22 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/server/index.js +40 -19
package/dist/index.cjs
CHANGED
|
@@ -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
|
}
|