浏览代码

Added experimental optimization on AirMusic serch caching logic

Toby Chui 3 年之前
父节点
当前提交
84709246c8
共有 1 个文件被更改,包括 10 次插入1 次删除
  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