|
@@ -44,17 +44,17 @@ func (rh *RenderHandler) BuildCacheForFolder(fsh *filesystem.FileSystemHandler,
|
|
rpath, _ := fshAbs.VirtualPathToRealPath(vpath, username)
|
|
rpath, _ := fshAbs.VirtualPathToRealPath(vpath, username)
|
|
|
|
|
|
//Get a list of all files inside this path
|
|
//Get a list of all files inside this path
|
|
- files, err := fshAbs.Glob(filepath.ToSlash(filepath.Clean(rpath)) + "/*")
|
|
|
|
|
|
+ fis, err := fshAbs.ReadDir(filepath.ToSlash(filepath.Clean(rpath)))
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- for _, file := range files {
|
|
|
|
|
|
+ for _, fi := range fis {
|
|
//Load Cache in generate mode
|
|
//Load Cache in generate mode
|
|
- rh.LoadCache(fsh, file, true)
|
|
|
|
|
|
+ rh.LoadCache(fsh, filepath.Join(rpath, fi.Name()), true)
|
|
}
|
|
}
|
|
|
|
|
|
//Check if the cache folder has file. If not, remove it
|
|
//Check if the cache folder has file. If not, remove it
|
|
- cachedFiles, _ := fshAbs.Glob(filepath.ToSlash(filepath.Join(filepath.Clean(rpath), "/.metadata/.cache/*")))
|
|
|
|
|
|
+ cachedFiles, _ := fshAbs.ReadDir(filepath.ToSlash(filepath.Join(filepath.Clean(rpath), "/.metadata/.cache/")))
|
|
if len(cachedFiles) == 0 {
|
|
if len(cachedFiles) == 0 {
|
|
fshAbs.RemoveAll(filepath.ToSlash(filepath.Join(filepath.Clean(rpath), "/.metadata/.cache/")) + "/")
|
|
fshAbs.RemoveAll(filepath.ToSlash(filepath.Join(filepath.Clean(rpath), "/.metadata/.cache/")) + "/")
|
|
}
|
|
}
|
|
@@ -223,7 +223,7 @@ func (rh *RenderHandler) HandleLoadCache(w http.ResponseWriter, r *http.Request,
|
|
oldc.(*websocket.Conn).Close()
|
|
oldc.(*websocket.Conn).Close()
|
|
}
|
|
}
|
|
|
|
|
|
- files, err := fsh.FileSystemAbstraction.Glob(targetPath + "/*")
|
|
|
|
|
|
+ fis, err := fsh.FileSystemAbstraction.ReadDir(targetPath)
|
|
if err != nil {
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
w.Write([]byte("500 - Internal Server Error"))
|
|
w.Write([]byte("500 - Internal Server Error"))
|
|
@@ -255,16 +255,16 @@ func (rh *RenderHandler) HandleLoadCache(w http.ResponseWriter, r *http.Request,
|
|
|
|
|
|
pendingFiles := []string{}
|
|
pendingFiles := []string{}
|
|
pendingFolders := []string{}
|
|
pendingFolders := []string{}
|
|
- for _, file := range files {
|
|
|
|
- if isDir(file) {
|
|
|
|
- pendingFiles = append(pendingFiles, file)
|
|
|
|
|
|
+ for _, fileInfo := range fis {
|
|
|
|
+ if fileInfo.IsDir() {
|
|
|
|
+ pendingFiles = append(pendingFiles, filepath.Join(targetPath, fileInfo.Name()))
|
|
} else {
|
|
} else {
|
|
- pendingFolders = append(pendingFolders, file)
|
|
|
|
|
|
+ pendingFolders = append(pendingFolders, filepath.Join(targetPath, fileInfo.Name()))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pendingFiles = append(pendingFiles, pendingFolders...)
|
|
pendingFiles = append(pendingFiles, pendingFolders...)
|
|
|
|
|
|
- files = fssort.SortFileList(pendingFiles, sortmode)
|
|
|
|
|
|
+ files := fssort.SortFileList(pendingFiles, sortmode)
|
|
|
|
|
|
//Updated implementation 24/12/2020: Load image with cache first before rendering those without
|
|
//Updated implementation 24/12/2020: Load image with cache first before rendering those without
|
|
for _, file := range files {
|
|
for _, file := range files {
|
|
@@ -377,32 +377,3 @@ func RemoveCache(fsh *filesystem.FileSystemHandler, file string) error {
|
|
return errors.New("Thumbnail cache not exists for this file")
|
|
return errors.New("Thumbnail cache not exists for this file")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-func specialGlob(fsh *filesystem.FileSystemHandler, path string) ([]string, error) {
|
|
|
|
- fshAbs := fsh.FileSystemAbstraction
|
|
|
|
- files, err := fshAbs.Glob(path)
|
|
|
|
- if err != nil {
|
|
|
|
- return []string{}, err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if strings.Contains(path, "[") == true || strings.Contains(path, "]") == true {
|
|
|
|
- if len(files) == 0 {
|
|
|
|
- //Handle reverse check. Replace all [ and ] with *
|
|
|
|
- newSearchPath := strings.ReplaceAll(path, "[", "?")
|
|
|
|
- newSearchPath = strings.ReplaceAll(newSearchPath, "]", "?")
|
|
|
|
- //Scan with all the similar structure except [ and ]
|
|
|
|
- tmpFilelist, _ := filepath.Glob(newSearchPath)
|
|
|
|
- for _, file := range tmpFilelist {
|
|
|
|
- file = filepath.ToSlash(file)
|
|
|
|
- if strings.Contains(file, filepath.ToSlash(filepath.Dir(path))) {
|
|
|
|
- files = append(files, file)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //Convert all filepaths to slash
|
|
|
|
- for i := 0; i < len(files); i++ {
|
|
|
|
- files[i] = filepath.ToSlash(files[i])
|
|
|
|
- }
|
|
|
|
- return files, nil
|
|
|
|
-}
|
|
|