|
@@ -2503,48 +2503,98 @@ func system_fs_handleList(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
|
|
|
//Check for really special exception in where the path contains [ or ] which cannot be handled via Golang Glob function
|
|
|
- files, err := fshAbs.Glob(realpath + "/*")
|
|
|
+ /*
|
|
|
+ files, err := fshAbs.Glob(realpath + "/*")
|
|
|
+ if err != nil {
|
|
|
+ systemWideLogger.PrintAndLog("File System", "Unable to list dir: "+err.Error(), err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var shortCutInfo *shortcut.ShortcutData = nil
|
|
|
+ for _, v := range files {
|
|
|
+ //Check if it is hidden file
|
|
|
+ isHidden, _ := hidden.IsHidden(v, false)
|
|
|
+ if showHidden != "true" && isHidden {
|
|
|
+ //Skipping hidden files
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ //Check if this is an aodb file
|
|
|
+ if filepath.Base(v) == "aofs.db" || filepath.Base(v) == "aofs.db.lock" {
|
|
|
+ //Database file (reserved)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ //Check if it is shortcut file. If yes, render a shortcut data struct
|
|
|
+ if filepath.Ext(v) == ".shortcut" {
|
|
|
+ //This is a shortcut file
|
|
|
+ shorcutData, err := shortcut.ReadShortcut(v)
|
|
|
+ if err == nil {
|
|
|
+ shortCutInfo = shorcutData
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fstat, _ := fshAbs.Stat(v)
|
|
|
+
|
|
|
+ rawsize := fstat.Size()
|
|
|
+ modtime := fstat.ModTime().Unix()
|
|
|
+ thisvPath, _ := fshAbs.RealPathToVirtualPath(v, userinfo.Username)
|
|
|
+ thisFile := filesystem.FileData{
|
|
|
+ Filename: filepath.Base(v),
|
|
|
+ Filepath: currentDir + filepath.Base(v),
|
|
|
+ Realpath: v,
|
|
|
+ IsDir: fstat.IsDir(),
|
|
|
+ Filesize: rawsize,
|
|
|
+ Displaysize: filesystem.GetFileDisplaySize(rawsize, 2),
|
|
|
+ ModTime: modtime,
|
|
|
+ IsShared: shareManager.FileIsShared(userinfo, thisvPath),
|
|
|
+ Shortcut: shortCutInfo,
|
|
|
+ }
|
|
|
+
|
|
|
+ parsedFilelist = append(parsedFilelist, thisFile)
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ files, err := fshAbs.ReadDir(realpath)
|
|
|
if err != nil {
|
|
|
- systemWideLogger.PrintAndLog("File System", "Unable to list dir: "+err.Error(), err)
|
|
|
+ systemWideLogger.PrintAndLog("File System", "Unable to read dir: "+err.Error(), err)
|
|
|
return
|
|
|
}
|
|
|
- var shortCutInfo *shortcut.ShortcutData = nil
|
|
|
- for _, v := range files {
|
|
|
+
|
|
|
+ for _, f := range files {
|
|
|
//Check if it is hidden file
|
|
|
- isHidden, _ := hidden.IsHidden(v, false)
|
|
|
+ isHidden, _ := hidden.IsHidden(f.Name(), false)
|
|
|
if showHidden != "true" && isHidden {
|
|
|
//Skipping hidden files
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
//Check if this is an aodb file
|
|
|
- if filepath.Base(v) == "aofs.db" || filepath.Base(v) == "aofs.db.lock" {
|
|
|
+ if f.Name() == "aofs.db" || f.Name() == "aofs.db.lock" {
|
|
|
//Database file (reserved)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
//Check if it is shortcut file. If yes, render a shortcut data struct
|
|
|
- if filepath.Ext(v) == ".shortcut" {
|
|
|
+ var shortCutInfo *shortcut.ShortcutData = nil
|
|
|
+ if filepath.Ext(f.Name()) == ".shortcut" {
|
|
|
//This is a shortcut file
|
|
|
- shorcutData, err := shortcut.ReadShortcut(v)
|
|
|
+ shorcutData, err := shortcut.ReadShortcut(f.Name())
|
|
|
if err == nil {
|
|
|
shortCutInfo = shorcutData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fstat, _ := fshAbs.Stat(v)
|
|
|
-
|
|
|
- rawsize := fstat.Size()
|
|
|
- modtime := fstat.ModTime().Unix()
|
|
|
- thisvPath, _ := fshAbs.RealPathToVirtualPath(v, userinfo.Username)
|
|
|
+ statInfo, _ := f.Info()
|
|
|
+ thisvPath, _ := fshAbs.RealPathToVirtualPath(filepath.Join(realpath, f.Name()), userinfo.Username)
|
|
|
thisFile := filesystem.FileData{
|
|
|
- Filename: filepath.Base(v),
|
|
|
- Filepath: currentDir + filepath.Base(v),
|
|
|
- Realpath: v,
|
|
|
- IsDir: fstat.IsDir(),
|
|
|
- Filesize: rawsize,
|
|
|
- Displaysize: filesystem.GetFileDisplaySize(rawsize, 2),
|
|
|
- ModTime: modtime,
|
|
|
+ Filename: f.Name(),
|
|
|
+ Filepath: currentDir + f.Name(),
|
|
|
+ Realpath: filepath.ToSlash(filepath.Join(realpath, f.Name())),
|
|
|
+ IsDir: f.IsDir(),
|
|
|
+ Filesize: statInfo.Size(),
|
|
|
+ Displaysize: filesystem.GetFileDisplaySize(statInfo.Size(), 2),
|
|
|
+ ModTime: statInfo.ModTime().Unix(),
|
|
|
IsShared: shareManager.FileIsShared(userinfo, thisvPath),
|
|
|
Shortcut: shortCutInfo,
|
|
|
}
|
|
@@ -2607,19 +2657,35 @@ func system_fs_handleDirHash(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
//Get a list of files in this directory
|
|
|
currentDir = filepath.ToSlash(filepath.Clean(rpath)) + "/"
|
|
|
- filesInDir, err := fshAbs.Glob(currentDir + "*")
|
|
|
+ /*
|
|
|
+ filesInDir, err := fshAbs.Glob(currentDir + "*")
|
|
|
+ if err != nil {
|
|
|
+ common.SendErrorResponse(w, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ filenames := []string{}
|
|
|
+ for _, file := range filesInDir {
|
|
|
+ if len(filepath.Base(file)) > 0 && string([]rune(filepath.Base(file))[0]) != "." {
|
|
|
+ //Ignore hidden files
|
|
|
+ filenames = append(filenames, filepath.Base(file))
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ */
|
|
|
+ finfos, err := fshAbs.ReadDir(rpath)
|
|
|
if err != nil {
|
|
|
common.SendErrorResponse(w, err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
filenames := []string{}
|
|
|
- for _, file := range filesInDir {
|
|
|
- if len(filepath.Base(file)) > 0 && string([]rune(filepath.Base(file))[0]) != "." {
|
|
|
+ for _, fi := range finfos {
|
|
|
+ isHiddenFile, _ := hidden.IsHidden(fi.Name(), false)
|
|
|
+ if len(fi.Name()) > 0 && !isHiddenFile {
|
|
|
//Ignore hidden files
|
|
|
- filenames = append(filenames, filepath.Base(file))
|
|
|
+ filenames = append(filenames, fi.Name())
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
sort.Strings(filenames)
|