|
@@ -528,25 +528,26 @@ func desktop_theme_handler(w http.ResponseWriter, r *http.Request) {
|
|
}
|
|
}
|
|
} else if loadUserTheme != "" {
|
|
} else if loadUserTheme != "" {
|
|
//Load user theme base on folder path
|
|
//Load user theme base on folder path
|
|
- userFsh, err := GetFsHandlerByUUID("user:/")
|
|
|
|
|
|
+ targetFsh, err := userinfo.GetFileSystemHandlerFromVirtualPath(loadUserTheme)
|
|
if err != nil {
|
|
if err != nil {
|
|
utils.SendErrorResponse(w, "Unable to resolve user root path")
|
|
utils.SendErrorResponse(w, "Unable to resolve user root path")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- userFshAbs := userFsh.FileSystemAbstraction
|
|
|
|
- rpath, err := userFshAbs.VirtualPathToRealPath(loadUserTheme, userinfo.Username)
|
|
|
|
|
|
+
|
|
|
|
+ fshAbs := targetFsh.FileSystemAbstraction
|
|
|
|
+ rpath, err := fshAbs.VirtualPathToRealPath(loadUserTheme, userinfo.Username)
|
|
if err != nil {
|
|
if err != nil {
|
|
utils.SendErrorResponse(w, "Custom folder load failed")
|
|
utils.SendErrorResponse(w, "Custom folder load failed")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
//Check if the folder exists
|
|
//Check if the folder exists
|
|
- if !userFshAbs.FileExists(rpath) {
|
|
|
|
|
|
+ if !fshAbs.FileExists(rpath) {
|
|
utils.SendErrorResponse(w, "Custom folder load failed")
|
|
utils.SendErrorResponse(w, "Custom folder load failed")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- if userinfo.CanRead(loadUserTheme) == false {
|
|
|
|
|
|
+ if !userinfo.CanRead(loadUserTheme) {
|
|
//No read permission
|
|
//No read permission
|
|
utils.SendErrorResponse(w, "Permission denied")
|
|
utils.SendErrorResponse(w, "Permission denied")
|
|
return
|
|
return
|
|
@@ -554,20 +555,34 @@ func desktop_theme_handler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
//Scan for jpg, gif or png
|
|
//Scan for jpg, gif or png
|
|
imageList := []string{}
|
|
imageList := []string{}
|
|
- scanPath := filepath.ToSlash(filepath.Clean(rpath)) + "/"
|
|
|
|
- pngFiles, _ := filepath.Glob(scanPath + "*.png")
|
|
|
|
- jpgFiles, _ := filepath.Glob(scanPath + "*.jpg")
|
|
|
|
- gifFiles, _ := filepath.Glob(scanPath + "*.gif")
|
|
|
|
-
|
|
|
|
- //Merge all 3 slice into one image list
|
|
|
|
- imageList = append(imageList, pngFiles...)
|
|
|
|
- imageList = append(imageList, jpgFiles...)
|
|
|
|
- imageList = append(imageList, gifFiles...)
|
|
|
|
|
|
+ /*
|
|
|
|
+ scanPath := filepath.ToSlash(filepath.Clean(rpath)) + "/"
|
|
|
|
+ pngFiles, _ := filepath.Glob(scanPath + "*.png")
|
|
|
|
+ jpgFiles, _ := filepath.Glob(scanPath + "*.jpg")
|
|
|
|
+ gifFiles, _ := filepath.Glob(scanPath + "*.gif")
|
|
|
|
+
|
|
|
|
+ //Merge all 3 slice into one image list
|
|
|
|
+ imageList = append(imageList, pngFiles...)
|
|
|
|
+ imageList = append(imageList, jpgFiles...)
|
|
|
|
+ imageList = append(imageList, gifFiles...)
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ files, err := fshAbs.ReadDir(rpath)
|
|
|
|
+ if err != nil {
|
|
|
|
+ utils.SendErrorResponse(w, err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, file := range files {
|
|
|
|
+ ext := filepath.Ext(file.Name())
|
|
|
|
+ if utils.StringInArray([]string{".png", ".jpg", ".gif"}, ext) {
|
|
|
|
+ imageList = append(imageList, arozfs.ToSlash(filepath.Join(rpath, file.Name())))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//Convert the image list back to vpaths
|
|
//Convert the image list back to vpaths
|
|
virtualImageList := []string{}
|
|
virtualImageList := []string{}
|
|
for _, image := range imageList {
|
|
for _, image := range imageList {
|
|
- vpath, err := userFshAbs.RealPathToVirtualPath(image, userinfo.Username)
|
|
|
|
|
|
+ vpath, err := fshAbs.RealPathToVirtualPath(image, userinfo.Username)
|
|
if err != nil {
|
|
if err != nil {
|
|
continue
|
|
continue
|
|
}
|
|
}
|