fix(mobile): don't stack an upload with itself (#31851)

This commit is contained in:
Santo Shakil
2026-09-28 22:15:04 +06:00
committed by GitHub
parent ae49913223
commit 638b6ac553
2 changed files with 10 additions and 1 deletions
@@ -204,7 +204,7 @@ class AssetService {
try {
// previous_checksum still points at the version the server had before this upload
final previousId = await _localRepository.getPreviousRemoteId(localId);
if (previousId != null) {
if (previousId != null && previousId != remoteId) {
await _apiRepository.stack([remoteId, previousId]);
}
} finally {
@@ -150,6 +150,15 @@ void main() {
verify(() => mocks.localAsset.repo.updatePreviousChecksum('local', 'sha')).called(1);
});
test('does not stack an upload onto itself', () async {
when(() => mocks.localAsset.repo.getPreviousRemoteId('local')).thenAnswer((_) async => 'remote');
await sut.stackEditedUpload('local', 'remote', 'sha');
verifyNever(() => apiRepository.stack(any()));
verify(() => mocks.localAsset.repo.updatePreviousChecksum('local', 'sha')).called(1);
});
test('records the uploaded checksum even when the stack call fails', () async {
when(() => mocks.localAsset.repo.getPreviousRemoteId('local')).thenAnswer((_) async => 'previous');
when(() => apiRepository.stack(any())).thenThrow(Exception('offline'));