diff options
| author | JosJuice <josjuice@gmail.com> | 2021-11-19 22:01:01 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2021-11-19 22:58:05 +0100 |
| commit | c2aa2818bea25a1b541fc0d25688d4233ffab055 (patch) | |
| tree | 625c568c3ac72463314506d3236ebba6df588377 /Source/Android/app/src/main/java | |
| parent | bb475391d2a0ae9e5acd57a00e609618fcbf3ec9 (diff) | |
Android: Make rescan on app start work again
I haven't fully confirmed why the previous commit broke this,
but I imagine it's due to AfterDirectoryInitializationRunner
executing in a different order than before, resulting in
startRescan running before startLoad.
Diffstat (limited to 'Source/Android/app/src/main/java')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java index eaa2f3524f..2364a3800c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheManager.java @@ -26,6 +26,7 @@ public final class GameFileCacheManager private static GameFileCache gameFileCache = null; private static final MutableLiveData<GameFile[]> gameFiles = new MutableLiveData<>(new GameFile[]{}); + private static boolean runRescanAfterLoad = false; private static final ExecutorService executor = Executors.newFixedThreadPool(1); private static final MutableLiveData<Boolean> loadInProgress = new MutableLiveData<>(false); @@ -135,7 +136,8 @@ public final class GameFileCacheManager /** * Asynchronously scans for games in the user's configured folders, * updating the game file cache with the results. - * If startLoad hasn't been called before this, this has no effect. + * If loading the game file cache hasn't started or hasn't finished, + * the execution of this will be postponed until it finishes. */ public static void startRescan(Context context) { @@ -190,17 +192,33 @@ public final class GameFileCacheManager } } + if (runRescanAfterLoad) + { + rescanInProgress.postValue(true); + } + loadInProgress.postValue(false); + + if (runRescanAfterLoad) + { + runRescanAfterLoad = false; + rescan(); + } } /** * Scans for games in the user's configured folders, * updating the game file cache with the results. - * If load hasn't been called before this, this has no effect. + * If load hasn't been called before this, the execution of this + * will be postponed until after load runs. */ private static void rescan() { - if (gameFileCache != null) + if (gameFileCache == null) + { + runRescanAfterLoad = true; + } + else { String[] gamePaths = GameFileCache.getAllGamePaths(); |
