Browse Source

Fixed agi filelib list root issues with virtual file systems

Toby Chui 3 years ago
parent
commit
1fef05afc4
3 changed files with 14 additions and 3 deletions
  1. 11 2
      mod/agi/agi.file.go
  2. 2 0
      web/Music/functions/listSong.js
  3. 1 1
      web/Music/index.html

+ 11 - 2
mod/agi/agi.file.go

@@ -230,8 +230,15 @@ func (g *Gateway) injectFileLibFunctions(vm *otto.Otto, u *user.User) {
 			return reply
 			return reply
 		}
 		}
 		results := []string{}
 		results := []string{}
-		err = filepath.Walk(rpath, func(path string, info os.FileInfo, err error) error {
+		filepath.Walk(rpath, func(path string, info os.FileInfo, err error) error {
+			if err != nil {
+				//Ignore this error file and continue
+				return nil
+			}
 			thisVpath, err := realpathToVirtualpath(path, u)
 			thisVpath, err := realpathToVirtualpath(path, u)
+			if err != nil {
+				return nil
+			}
 			if mode == "file" {
 			if mode == "file" {
 				if !info.IsDir() {
 				if !info.IsDir() {
 					results = append(results, thisVpath)
 					results = append(results, thisVpath)
@@ -275,7 +282,9 @@ func (g *Gateway) injectFileLibFunctions(vm *otto.Otto, u *user.User) {
 			rootDirs := []string{}
 			rootDirs := []string{}
 			fileHandlers := u.GetAllFileSystemHandler()
 			fileHandlers := u.GetAllFileSystemHandler()
 			for _, fsh := range fileHandlers {
 			for _, fsh := range fileHandlers {
-				if fsh.Hierarchy != "backup" {
+				if fsh.Hierarchy == "backup" || fsh.Filesystem == "virtual" {
+
+				} else {
 					rootDirs = append(rootDirs, fsh.UUID+":/")
 					rootDirs = append(rootDirs, fsh.UUID+":/")
 				}
 				}
 			}
 			}

+ 2 - 0
web/Music/functions/listSong.js

@@ -125,6 +125,7 @@ function handleUserRequest(){
             }else if (listSong.substr(0,7) == "search:"){
             }else if (listSong.substr(0,7) == "search:"){
                 //Search mode
                 //Search mode
                 var keyword = listSong.substr(7)
                 var keyword = listSong.substr(7)
+                keyword = keyword.toLowerCase();
                 var songData = [];
                 var songData = [];
 
 
                 var cachedList = readDBItem("AirMusic", "cache");
                 var cachedList = readDBItem("AirMusic", "cache");
@@ -163,6 +164,7 @@ function handleUserRequest(){
                     var thisFile = allfilelist[k];
                     var thisFile = allfilelist[k];
                     var ext = allfilelist[k].split('.').pop();
                     var ext = allfilelist[k].split('.').pop();
                     var filename = allfilelist[k].split('/').pop();
                     var filename = allfilelist[k].split('/').pop();
+                    filename = filename.toLowerCase();
                     if (IsSupportExt(ext) == true && filename.indexOf(keyword) !== -1 && !IsMetaFile(allfilelist[k])){
                     if (IsSupportExt(ext) == true && filename.indexOf(keyword) !== -1 && !IsMetaFile(allfilelist[k])){
                         //This file match our ext req and keyword exists
                         //This file match our ext req and keyword exists
                         var thisSongData = [];
                         var thisSongData = [];

+ 1 - 1
web/Music/index.html

@@ -29,7 +29,7 @@
 	<button class="ts right item icon AMmenu noBorder button" onClick="enterSearchMode();"><i class="search icon"></i></button>
 	<button class="ts right item icon AMmenu noBorder button" onClick="enterSearchMode();"><i class="search icon"></i></button>
 	<!-- <button class="ts right item icon AMmenu noBorder button"><i class="ellipsis vertical icon"></i></button> -->
 	<!-- <button class="ts right item icon AMmenu noBorder button"><i class="ellipsis vertical icon"></i></button> -->
 </div>
 </div>
-<div id="searchModeMenu" class="ts basic fluid AMmenu menu bottomBlue" style="z-index:85;position:fixed;position:top:0px;left:0px;width:100%;height:51px;display:none;">
+<div id="searchModeMenu" class="ts basic fluid AMmenu menu bottomBlue" style="z-index:85;position:fixed;top:0px;left:0px;width:100%;height:51px;display:none;">
     <button class="ts item icon noBorder AMmenu button" onClick="exitSearchMode();"><i class="arrow left icon"></i></button>
     <button class="ts item icon noBorder AMmenu button" onClick="exitSearchMode();"><i class="arrow left icon"></i></button>
 	<div class="ts fluid input" >
 	<div class="ts fluid input" >
 		<input id="searchInputBar" type="text" style="background-color:rgb(48, 48, 48);border:0px !important;border-bottom:2px solid rgb(60, 60, 60) !important;margin-bottom:3px;color:white;" placeholder="Search Music">
 		<input id="searchInputBar" type="text" style="background-color:rgb(48, 48, 48);border:0px !important;border-bottom:2px solid rgb(60, 60, 60) !important;margin-bottom:3px;color:white;" placeholder="Search Music">