Pārlūkot izejas kodu

Fixed agi file glob and aglob show hidden files issue

Toby Chui 3 gadi atpakaļ
vecāks
revīzija
2c9c5c2268
1 mainītis faili ar 11 papildinājumiem un 0 dzēšanām
  1. 11 0
      mod/agi/agi.file.go

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

@@ -10,6 +10,7 @@ import (
 	"github.com/robertkrimen/otto"
 	fs "imuslab.com/arozos/mod/filesystem"
 	"imuslab.com/arozos/mod/filesystem/fssort"
+	"imuslab.com/arozos/mod/filesystem/hidden"
 	user "imuslab.com/arozos/mod/user"
 )
 
@@ -336,6 +337,11 @@ func (g *Gateway) injectFileLibFunctions(vm *otto.Otto, u *user.User) {
 			//Return the results in virtual paths
 			results := []string{}
 			for _, file := range newFilelist {
+				isHidden, _ := hidden.IsHidden(file, true)
+				if isHidden {
+					//Hidden file. Skip this
+					continue
+				}
 				thisRpath, _ := realpathToVirtualpath(filepath.ToSlash(file), u)
 				results = append(results, thisRpath)
 			}
@@ -402,6 +408,11 @@ func (g *Gateway) injectFileLibFunctions(vm *otto.Otto, u *user.User) {
 		//Parse the results (Only extract the filepath)
 		results := []string{}
 		for _, filename := range newFilelist {
+			isHidden, _ := hidden.IsHidden(filename, true)
+			if isHidden {
+				//Hidden file. Skip this
+				continue
+			}
 			thisVpath, _ := u.RealPathToVirtualPath(filename)
 			results = append(results, thisVpath)
 		}