瀏覽代碼

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 年之前
父節點
當前提交
5b5a68552d
共有 1 個文件被更改,包括 6 次插入0 次删除
  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)