Browse Source

Added experimental optimization on AirMusic serch caching logic

Toby Chui 3 years ago
parent
commit
84709246c8
1 changed files with 10 additions and 1 deletions
  1. 10 1
      web/Music/functions/listSong.js

+ 10 - 1
web/Music/functions/listSong.js

@@ -152,7 +152,16 @@ function handleUserRequest(){
                         cachedList = JSON.parse(cachedList);
                         for (var j = 0; j < cachedList.length; j++){
                             var thisCachedSong = cachedList[j];
-                            allfilelist.push(thisCachedSong[0].replace("/media?file=", ""));
+                            var thisFilepath = thisCachedSong[0].replace("/media?file=", "");
+                            //Check if this file still exists. If not, get realtime list instead.
+                            if (filelib.fileExists(thisFilepath)){
+                                allfilelist.push(thisFilepath);
+                            }else{
+                                //Cache outdated. Rescanning now
+                                allfilelist = getRealtimeAllFleList();
+                                execd("buildCache.js")
+                                break;
+                            }
                         }
                     }catch(ex){
                         //Fallback