Parcourir la source

Optimized list all photo api

Toby Chui il y a 3 ans
Parent
commit
39d7af5aef
1 fichiers modifiés avec 6 ajouts et 4 suppressions
  1. 6 4
      web/Photo/backend/imagedb.js

+ 6 - 4
web/Photo/backend/imagedb.js

@@ -93,8 +93,8 @@ function setNNModel(newNNM){
 }
 
 //Check if this photo shd be rendered
-function checkIsInExcludeFolders(filename){
-    var excludeRootFolders = getExcludeFolders();
+function checkIsInExcludeFolders(filename, excludeFiles){
+    var excludeRootFolders = excludeFiles;
     var pathinfo = filename.split("/");
     if (pathinfo.length > 2){
         var basefolder = pathinfo[2];
@@ -113,13 +113,14 @@ function checkIsInExcludeFolders(filename){
 function getAllImageFiles(){
     var results = [];
     var possibleRoots = getAllPossibleRoots();
+    var excludeFiles = getExcludeFolders();
     for ( var i = 0; i < possibleRoots.length; i++){
         var thisRootInfo = possibleRoots[i];
         var allFilesInThisPhotoRoot = filelib.walk(thisRootInfo[2]);
         for ( var j = 0; j < allFilesInThisPhotoRoot.length; j++){
             var thisFile = allFilesInThisPhotoRoot[j];
             if (!filelib.isDir(thisFile) && isSupportedImage(thisFile) && !inCacheFolder(thisFile)){
-                if (!checkIsInExcludeFolders(thisFile)){
+                if (!checkIsInExcludeFolders(thisFile, excludeFiles)){
                     results.push(thisFile);
                 }
                 
@@ -132,6 +133,7 @@ function getAllImageFiles(){
 
 //Get all the image files exists in given root as rootID:/Photo/*
 function getAllImageFilesInRoot(targetRootID){
+    var excludeFiles = getExcludeFolders();
     if (targetRootID.indexOf(":") >= 0){
         targetRootID = targetRootID.split(":")[0];
     }
@@ -140,7 +142,7 @@ function getAllImageFilesInRoot(targetRootID){
     for ( var j = 0; j < allFilesInThisPhotoRoot.length; j++){
         var thisFile = allFilesInThisPhotoRoot[j];
         if (!filelib.isDir(thisFile) && isSupportedImage(thisFile) && !inCacheFolder(thisFile)){
-            if (!checkIsInExcludeFolders(thisFile)){
+            if (!checkIsInExcludeFolders(thisFile, excludeFiles)){
                 results.push(thisFile);
             }