@lacrous/omnicloud 0.2.27 → 0.2.29
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 +15 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/server/index.js +16 -11
- package/server/web/assets/{index-Dn6lUGQf.js → index-Cimv9hDI.js} +1 -1
- package/server/web/index.html +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1283,10 +1283,10 @@ var StorageEngine = class {
|
|
|
1283
1283
|
}
|
|
1284
1284
|
}
|
|
1285
1285
|
/** Read-only search for stored objects with this content hash and size. */
|
|
1286
|
-
async findByCaption(
|
|
1286
|
+
async findByCaption(caption, size) {
|
|
1287
1287
|
if (!this.provider.findByCaption) return null;
|
|
1288
1288
|
try {
|
|
1289
|
-
return await this.provider.findByCaption(
|
|
1289
|
+
return await this.provider.findByCaption(caption, size);
|
|
1290
1290
|
} catch (error) {
|
|
1291
1291
|
throw mapProviderError("Storage lookup failed", error);
|
|
1292
1292
|
}
|
|
@@ -1512,6 +1512,9 @@ function uploadRequestFingerprint(input) {
|
|
|
1512
1512
|
function contentSha256(input) {
|
|
1513
1513
|
return input.spooled?.sha256 ?? sha256Hex(input.data ?? Buffer.alloc(0));
|
|
1514
1514
|
}
|
|
1515
|
+
function uploadCaption(sha256, operationId) {
|
|
1516
|
+
return `${sha256}:${operationId}`;
|
|
1517
|
+
}
|
|
1515
1518
|
function contentSize(input) {
|
|
1516
1519
|
return input.spooled?.size ?? input.data?.byteLength ?? 0;
|
|
1517
1520
|
}
|
|
@@ -1593,6 +1596,7 @@ var FileService = class {
|
|
|
1593
1596
|
}
|
|
1594
1597
|
try {
|
|
1595
1598
|
const record = await this.performUpload(userId, input, {
|
|
1599
|
+
caption: uploadCaption(contentSha256(input), op.operationId),
|
|
1596
1600
|
onStored: async (stored) => {
|
|
1597
1601
|
await operations.update(op.id, { telegramMessageId: Number(stored.messageId) });
|
|
1598
1602
|
await operations.claim(op.id, "UPLOADING", "COMMITTING");
|
|
@@ -1624,7 +1628,7 @@ var FileService = class {
|
|
|
1624
1628
|
);
|
|
1625
1629
|
}
|
|
1626
1630
|
const engine = await this.engineFor(userId);
|
|
1627
|
-
const matches = await engine.findByCaption(op.sha256, op.size);
|
|
1631
|
+
const matches = await engine.findByCaption(uploadCaption(op.sha256, op.operationId), op.size);
|
|
1628
1632
|
if (matches === null) {
|
|
1629
1633
|
throw new ConflictError(
|
|
1630
1634
|
"This upload's outcome is unknown and the storage backend cannot search for it."
|
|
@@ -1729,8 +1733,9 @@ var FileService = class {
|
|
|
1729
1733
|
mimeType,
|
|
1730
1734
|
path: input.spooled.path,
|
|
1731
1735
|
size: input.spooled.size,
|
|
1732
|
-
sha256: input.spooled.sha256
|
|
1733
|
-
|
|
1736
|
+
sha256: input.spooled.sha256,
|
|
1737
|
+
caption: hooks.caption
|
|
1738
|
+
} : { name, mimeType, data: input.data, caption: hooks.caption },
|
|
1734
1739
|
control
|
|
1735
1740
|
);
|
|
1736
1741
|
await hooks.onStored?.(stored);
|
|
@@ -3098,7 +3103,7 @@ var TelegramStorageProvider = class {
|
|
|
3098
3103
|
file,
|
|
3099
3104
|
forceDocument: true,
|
|
3100
3105
|
workers: 1,
|
|
3101
|
-
caption: input.
|
|
3106
|
+
caption: input.caption,
|
|
3102
3107
|
// Surface transport-level progress to the caller. GramJS reports a
|
|
3103
3108
|
// 0..1 fraction. `isCanceled` lets us abort an in-flight upload.
|
|
3104
3109
|
progressCallback: Object.assign(
|
|
@@ -3257,18 +3262,18 @@ var TelegramStorageProvider = class {
|
|
|
3257
3262
|
return objects;
|
|
3258
3263
|
}
|
|
3259
3264
|
/**
|
|
3260
|
-
* Finds stored documents whose caption equals the
|
|
3265
|
+
* Finds stored documents whose caption equals the given caption and whose size
|
|
3261
3266
|
* matches. Used to recover an upload whose outcome was unknown.
|
|
3262
3267
|
*/
|
|
3263
|
-
async findByCaption(
|
|
3268
|
+
async findByCaption(caption, size) {
|
|
3264
3269
|
const matches = [];
|
|
3265
3270
|
try {
|
|
3266
3271
|
for await (const message of this.client.iterMessages(this.peer, {
|
|
3267
|
-
search:
|
|
3272
|
+
search: caption,
|
|
3268
3273
|
limit: 20
|
|
3269
3274
|
})) {
|
|
3270
3275
|
if (!(message instanceof import_telegram2.Api.Message)) continue;
|
|
3271
|
-
if (message.message !==
|
|
3276
|
+
if (message.message !== caption) continue;
|
|
3272
3277
|
const document = message.document;
|
|
3273
3278
|
if (!(document instanceof import_telegram2.Api.Document)) continue;
|
|
3274
3279
|
if (Number(document.size.toString()) !== size) continue;
|