[Android] Check db file exists to discover default folders

Geoffrey Métais git at videolan.org
Wed Apr 5 17:17:41 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Apr  5 17:05:18 2017 +0200| [2807ef481d7c9c64c7978d60ac5324eec81997e6] | committer: Geoffrey Métais

Check db file exists to discover default folders

> https://code.videolan.org/videolan/vlc-android/commit/2807ef481d7c9c64c7978d60ac5324eec81997e6
---

 vlc-android/src/org/videolan/vlc/MediaParsingService.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index 606b4fc..31fc75c 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -133,6 +133,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
                         mLastNotificationTime = System.currentTimeMillis();
                     }
                     mMedialibrary.setup();
+                    boolean shouldInit = !(new File(MediaParsingService.this.getCacheDir()+Medialibrary.VLC_MEDIA_DB_NAME).exists());
                     String[] storages = AndroidDevices.getMediaDirectories();
                     for (String storage : storages) {
                         boolean isMainStorage = TextUtils.equals(storage, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);
@@ -140,13 +141,12 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
                     }
                     if (mMedialibrary.init(MediaParsingService.this)) {
                         LocalBroadcastManager.getInstance(MediaParsingService.this).sendBroadcast(new Intent(VLCApplication.ACTION_MEDIALIBRARY_READY));
-                        if (firstRun) {
+                        if (shouldInit) {
                             for (String storage : storages)
                                 for (String folder : Medialibrary.getBlackList())
                                     mMedialibrary.banFolder(storage + folder);
                             for (File folder : Medialibrary.getDefaultFolders())
-                                if (folder.exists())
-                                    mMedialibrary.discover(folder.getPath());
+                                mMedialibrary.discover(folder.getPath());
                         } else if (upgrade) {
                             mMedialibrary.forceParserRetry();
                         }



More information about the Android mailing list