feat: verify embedded backup media checksums
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:crypto/crypto.dart' as crypto;
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@ -101,6 +102,7 @@ final class PathProviderLocalMediaStorage
|
||||
fileName: p.basename(file.path),
|
||||
mimeType: resource.payload['mimeType'] as String?,
|
||||
sizeBytes: bytes.length,
|
||||
sha256: crypto.sha256.convert(bytes).toString(),
|
||||
base64: base64Encode(bytes),
|
||||
),
|
||||
);
|
||||
@ -123,6 +125,9 @@ final class PathProviderLocalMediaStorage
|
||||
if (bytes == null) {
|
||||
continue;
|
||||
}
|
||||
if (crypto.sha256.convert(bytes).toString() != file.sha256) {
|
||||
continue;
|
||||
}
|
||||
final extension = p.extension(file.fileName).toLowerCase();
|
||||
final target = File(
|
||||
p.join(directory.path, '${file.mediaAssetId}$extension'),
|
||||
|
||||
Reference in New Issue
Block a user