mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
Reuse recent CDN locators
This commit is contained in:
@@ -198,6 +198,7 @@ import type {
|
||||
GetMessagesBetweenOptions,
|
||||
MaybeStaleCallHistory,
|
||||
ExistingAttachmentData,
|
||||
ExistingAttachmentUploadData,
|
||||
} from './Interface.std.js';
|
||||
import {
|
||||
AttachmentDownloadSource,
|
||||
@@ -559,6 +560,7 @@ export const DataReader: ServerReadableInterface = {
|
||||
|
||||
getStatisticsForLogging,
|
||||
|
||||
getMostRecentAttachmentUploadData,
|
||||
getBackupCdnObjectMetadata,
|
||||
getBackupAttachmentDownloadProgress,
|
||||
getAttachmentReferencesForMessages,
|
||||
@@ -3043,6 +3045,35 @@ function isAttachmentSafeToDelete(db: ReadableDB, path: string): boolean {
|
||||
return db.prepare(query, { pluck: true }).get(params) === 0;
|
||||
}
|
||||
|
||||
function getMostRecentAttachmentUploadData(
|
||||
db: ReadableDB,
|
||||
plaintextHash: string
|
||||
): ExistingAttachmentUploadData | undefined {
|
||||
const [query, params] = sql`
|
||||
SELECT
|
||||
key,
|
||||
digest,
|
||||
transitCdnKey AS cdnKey,
|
||||
transitCdnNumber AS cdnNumber,
|
||||
transitCdnUploadTimestamp AS uploadTimestamp,
|
||||
incrementalMac,
|
||||
incrementalMacChunkSize as chunkSize
|
||||
FROM message_attachments
|
||||
INDEXED BY message_attachments_plaintextHash
|
||||
WHERE
|
||||
plaintextHash = ${plaintextHash} AND
|
||||
key IS NOT NULL AND
|
||||
digest IS NOT NULL AND
|
||||
transitCdnKey IS NOT NULL AND
|
||||
transitCdnNumber IS NOT NULL AND
|
||||
transitCdnUploadTimestamp IS NOT NULL
|
||||
ORDER BY transitCdnUploadTimestamp DESC
|
||||
LIMIT 1
|
||||
`;
|
||||
|
||||
return db.prepare(query).get<ExistingAttachmentUploadData>(params);
|
||||
}
|
||||
|
||||
function _testOnlyRemoveMessageAttachments(
|
||||
db: WritableDB,
|
||||
timestamp: number
|
||||
|
||||
Reference in New Issue
Block a user