Permalink
Browse files

Delete Media URIs only after scanning chosen photos

Avoid race conditions caused by deleting all media URIs first (potentially causing Muzei to trigger a reload of new media URIs in that short period) before loading chosen photos.
  • Loading branch information...
ianhanniballake committed Oct 5, 2018
1 parent 8c7599a commit 81fea4263b0e09b19b11cf00d08bf6f0167d2a4d
@@ -91,8 +91,8 @@ class GalleryScanWorker(
.chosenPhotoDao()
.chosenPhotoBlocking(id)
return if (chosenPhoto != null) {
deleteMediaUris()
scanChosenPhoto(chosenPhoto)
deleteMediaUris()
Result.SUCCESS
} else {
Result.FAILURE
@@ -103,11 +103,10 @@ class GalleryScanWorker(
.chosenPhotosBlocking
val numChosenUris = chosenPhotos.size
if (numChosenUris > 0) {
deleteMediaUris()
// Now add all of the chosen photos
for (chosenPhoto in chosenPhotos) {
scanChosenPhoto(chosenPhoto)
}
deleteMediaUris()
return Result.SUCCESS
}
return addMediaUri()

0 comments on commit 81fea42

Please sign in to comment.