Skip to content

Commit

Permalink
Using creationDate instead of modificationDate (#668)
Browse files Browse the repository at this point in the history
Change shall avoid upload of duplicated photos since e.g. modificationDate can change if the photo was edited.

Co-authored-by: Michael Neuwert <[email protected]>
Co-authored-by: Matthias Hühne <[email protected]>
  • Loading branch information
3 people authored Apr 21, 2020
1 parent 0c1c582 commit 99b86e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ownCloud/Tasks/InstantMediaUploadTaskExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class InstantMediaUploadTaskExtension : ScheduledTaskAction {

if photoAssets.count > 0 {
MediaUploadQueue.shared.addUploads(Array(photoAssets), for: bookmark, at: path)
userDefaults.instantUploadPhotosAfter = photoAssets.last?.modificationDate
userDefaults.instantUploadPhotosAfter = photoAssets.last?.creationDate
Log.debug(tagged: ["INSTANT_MEDIA_UPLOAD"], "Last added photo asset modification date: \(String(describing: userDefaults.instantUploadPhotosAfter))")
}

Expand All @@ -95,7 +95,7 @@ class InstantMediaUploadTaskExtension : ScheduledTaskAction {

if videoAssets.count > 0 {
MediaUploadQueue.shared.addUploads(videoAssets, for: bookmark, at: path)
userDefaults.instantUploadVideosAfter = videoAssets.last?.modificationDate
userDefaults.instantUploadVideosAfter = videoAssets.last?.creationDate
Log.debug(tagged: ["INSTANT_MEDIA_UPLOAD"], "Last added video asset modification date: \(String(describing: userDefaults.instantUploadPhotosAfter))")
}
}
Expand Down Expand Up @@ -129,13 +129,13 @@ class InstantMediaUploadTaskExtension : ScheduledTaskAction {
let fetchOptions = PHFetchOptions()

if let date = createdAfter {
let creationDatePredicate = NSPredicate(format: "modificationDate > %@", date as NSDate)
let creationDatePredicate = NSPredicate(format: "creationDate > %@", date as NSDate)
fetchOptions.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [mediaTypesPredicate, creationDatePredicate])
} else {
fetchOptions.predicate = mediaTypesPredicate
}

let sort = NSSortDescriptor(key: "modificationDate", ascending: true)
let sort = NSSortDescriptor(key: "creationDate", ascending: true)
fetchOptions.sortDescriptors = [sort]

Log.debug(tagged: ["INSTANT_MEDIA_UPLOAD"], "Fetching assets with options \(fetchOptions.debugDescription)")
Expand Down

0 comments on commit 99b86e4

Please sign in to comment.