Bläddra i källkod

MediaLibraryService: Force rescan for 3.2.6

Due to the recent title behaviour changes from medialibrary, we need to
force rescan to avoid that the user have to do it manually.

ref medialibrary#191
Soomin Lee 5 år sedan
förälder
incheckning
5b5a68552d
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. 6 0
      SharedSources/MediaLibraryService.swift

+ 6 - 0
SharedSources/MediaLibraryService.swift

@@ -113,6 +113,7 @@ protocol MediaLibraryMigrationDelegate: class {
 class MediaLibraryService: NSObject {
     private static let databaseName: String = "medialibrary.db"
     private static let migrationKey: String = "MigratedToVLCMediaLibraryKit"
+    private static let didForceRescan: String = "MediaLibraryDidForceRescan"
 
     private var didMigrate = UserDefaults.standard.bool(forKey: MediaLibraryService.migrationKey)
     private var didFinishDiscovery = false
@@ -152,6 +153,11 @@ private extension MediaLibraryService {
             return
         }
 
+        if UserDefaults.standard.bool(forKey: MediaLibraryService.didForceRescan) == false {
+            medialib.forceRescan()
+            UserDefaults.standard.set(true, forKey: MediaLibraryService.didForceRescan)
+        }
+
         /* exclude Document directory from backup (QA1719) */
         if let documentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first {
             var excludeURL = URL(fileURLWithPath: documentPath)