fix: count checksum-corrupted media as missing on local backup import
Import result missingMediaCount compared restored assets against the backup's declared media file list, so an embedded file that failed sha256 verification was still treated as present. Compute it from the actually restored files instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@ -208,7 +208,12 @@ final class DataImportUseCase {
|
||||
mode: mode,
|
||||
importedAt: clock.now(),
|
||||
);
|
||||
return result.copyWith(missingMediaCount: _missingMediaCount(snapshot));
|
||||
return result.copyWith(
|
||||
missingMediaCount: _missingRestoredMediaCount(
|
||||
decoded,
|
||||
restoredMediaFiles,
|
||||
),
|
||||
);
|
||||
} on LocalBackupException {
|
||||
rethrow;
|
||||
} on Object {
|
||||
@ -4993,6 +4998,15 @@ int _missingMediaCount(LocalDataExportSnapshot snapshot) {
|
||||
.length;
|
||||
}
|
||||
|
||||
int _missingRestoredMediaCount(
|
||||
LocalDataExportSnapshot snapshot,
|
||||
Map<String, RestoredMediaFile> restoredFiles,
|
||||
) {
|
||||
return snapshot.mediaAssets
|
||||
.where((asset) => !restoredFiles.containsKey(asset.id))
|
||||
.length;
|
||||
}
|
||||
|
||||
bool _hasNameDuplicates(LocalDataExportSnapshot snapshot) {
|
||||
return _hasDuplicatesByName(snapshot.exercises) ||
|
||||
_hasDuplicatesByName(snapshot.programs) ||
|
||||
|
||||
Reference in New Issue
Block a user