Update backup locator proto.

This commit is contained in:
Clark
2024-04-16 15:01:32 -04:00
committed by Greyson Parrelli
parent d8bbfe2678
commit 5f31f5966c
3 changed files with 19 additions and 9 deletions

View File

@@ -25,8 +25,10 @@ class ArchivedAttachment : Attachment {
constructor( constructor(
contentType: String?, contentType: String?,
size: Long, size: Long,
cdn: Cdn, cdn: Int,
cdnKey: ByteArray, key: ByteArray,
cdnKey: String?,
archiveCdn: Int?,
archiveMediaName: String, archiveMediaName: String,
archiveMediaId: String, archiveMediaId: String,
digest: ByteArray, digest: ByteArray,
@@ -46,9 +48,9 @@ class ArchivedAttachment : Attachment {
transferState = AttachmentTable.TRANSFER_NEEDS_RESTORE, transferState = AttachmentTable.TRANSFER_NEEDS_RESTORE,
size = size, size = size,
fileName = null, fileName = null,
cdn = cdn, cdn = Cdn.fromCdnNumber(cdn),
remoteLocation = null, remoteLocation = cdnKey,
remoteKey = Base64.encodeWithoutPadding(cdnKey), remoteKey = Base64.encodeWithoutPadding(key),
remoteDigest = digest, remoteDigest = digest,
incrementalDigest = incrementalMac, incrementalDigest = incrementalMac,
fastPreflightId = null, fastPreflightId = null,
@@ -65,7 +67,7 @@ class ArchivedAttachment : Attachment {
audioHash = null, audioHash = null,
transformProperties = null transformProperties = null
) { ) {
this.archiveCdn = cdn.cdnNumber this.archiveCdn = archiveCdn ?: Cdn.CDN_3.cdnNumber
this.archiveMediaName = archiveMediaName this.archiveMediaName = archiveMediaName
this.archiveMediaId = archiveMediaId this.archiveMediaId = archiveMediaId
} }

View File

@@ -618,8 +618,10 @@ class ChatItemImportInserter(
return ArchivedAttachment( return ArchivedAttachment(
contentType = contentType, contentType = contentType,
size = pointer.backupLocator.size.toLong(), size = pointer.backupLocator.size.toLong(),
cdn = Cdn.fromCdnNumber(pointer.backupLocator.cdnNumber), cdn = pointer.backupLocator.transitCdnNumber ?: Cdn.CDN_0.cdnNumber,
cdnKey = pointer.backupLocator.key.toByteArray(), key = pointer.backupLocator.key.toByteArray(),
cdnKey = pointer.backupLocator.transitCdnKey,
archiveCdn = pointer.backupLocator.cdnNumber,
archiveMediaName = pointer.backupLocator.mediaName, archiveMediaName = pointer.backupLocator.mediaName,
archiveMediaId = backupState.backupKey.deriveMediaId(MediaName(pointer.backupLocator.mediaName)).encode(), archiveMediaId = backupState.backupKey.deriveMediaId(MediaName(pointer.backupLocator.mediaName)).encode(),
digest = pointer.backupLocator.digest.toByteArray(), digest = pointer.backupLocator.digest.toByteArray(),

View File

@@ -388,10 +388,16 @@ message FilePointer {
// References attachments in the backup (media) storage tier. // References attachments in the backup (media) storage tier.
message BackupLocator { message BackupLocator {
string mediaName = 1; string mediaName = 1;
uint32 cdnNumber = 2; // If present, the cdn number of the succesful upload.
// If empty/0, may still have been uploaded, and clients
// can discover the cdn number via the list endpoint.
optional uint32 cdnNumber = 2;
bytes key = 3; bytes key = 3;
bytes digest = 4; bytes digest = 4;
uint32 size = 5; uint32 size = 5;
// Fallback in case backup tier upload failed.
optional string transitCdnKey = 6;
optional uint32 transitCdnNumber = 7;
} }
// References attachments in the transit storage tier. // References attachments in the transit storage tier.