Name plaintext export attachment files by plaintext hash so they can be located from the exported json.

This commit is contained in:
Alex Hart
2026-09-23 16:00:20 -04:00
committed by Michelle Tang
parent d0b314d2d7
commit e2d96d1f2f
2 changed files with 6 additions and 1 deletions
@@ -186,7 +186,7 @@ object LocalArchiver {
val prefixDirs = HashMap<String, DocumentFile>()
for (attachment in attachments) {
if (cancellationSignal()) break
val mediaName = MediaName.forLocalBackupFilename(attachment.plaintextHash, attachment.localBackupKey.key)
val mediaName = MediaName.forPlaintextExportFilename(attachment.plaintextHash)
try {
val ext = attachment.contentType
@@ -20,6 +20,11 @@ value class MediaName(val name: String) {
fun forThumbnailFromMediaName(mediaName: String) = MediaName("${mediaName}_thumbnail")
fun forLocalBackupFilename(plaintextHash: ByteArray, localKey: ByteArray) = MediaName(Hex.toStringCondensed(CryptoUtil.sha256(plaintextHash + localKey)))
/**
* Since these are unencrypted, we don't want to create them via the local key.
*/
fun forPlaintextExportFilename(plaintextHash: ByteArray) = MediaName(Hex.toStringCondensed(plaintextHash))
/**
* For java, since it struggles with value classes.
*/