|
@@ -347,17 +347,17 @@ func system_fs_handleFileSearch(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- Handle low-memory upload operations
|
|
|
+Handle low-memory upload operations
|
|
|
|
|
|
- This function is specailly designed to work with low memory devices
|
|
|
- (e.g. ZeroPi / Orange Pi Zero with 512MB RAM)
|
|
|
+This function is specailly designed to work with low memory devices
|
|
|
+(e.g. ZeroPi / Orange Pi Zero with 512MB RAM)
|
|
|
|
|
|
- Two cases
|
|
|
- 1. Not Buffer FS + Huge File
|
|
|
- => Write chunks to fsa + merge to fsa
|
|
|
+Two cases
|
|
|
+1. Not Buffer FS + Huge File
|
|
|
+=> Write chunks to fsa + merge to fsa
|
|
|
|
|
|
- 2. Else
|
|
|
- => write chunks to tmp (via os package) + merge to fsa
|
|
|
+2. Else
|
|
|
+=> write chunks to tmp (via os package) + merge to fsa
|
|
|
*/
|
|
|
func system_fs_handleLowMemoryUpload(w http.ResponseWriter, r *http.Request) {
|
|
|
//Get user info
|
|
@@ -715,10 +715,10 @@ func system_fs_handleLowMemoryUpload(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- Handle FORM POST based upload
|
|
|
+Handle FORM POST based upload
|
|
|
|
|
|
- This function is design for general SBCs or computers with more than 2GB of RAM
|
|
|
- (e.g. Raspberry Pi 4 / Linux Server)
|
|
|
+This function is design for general SBCs or computers with more than 2GB of RAM
|
|
|
+(e.g. Raspberry Pi 4 / Linux Server)
|
|
|
*/
|
|
|
func system_fs_handleUpload(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
@@ -867,7 +867,7 @@ func system_fs_handleUpload(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendOK(w)
|
|
|
}
|
|
|
|
|
|
-//Validate if the copy and target process will involve file overwriting problem.
|
|
|
+// Validate if the copy and target process will involve file overwriting problem.
|
|
|
func system_fs_validateFileOpr(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -909,7 +909,7 @@ func system_fs_validateFileOpr(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendJSONResponse(w, string(jsonString))
|
|
|
}
|
|
|
|
|
|
-//Scan all directory and get trash file and send back results with WebSocket
|
|
|
+// Scan all directory and get trash file and send back results with WebSocket
|
|
|
func system_fs_WebSocketScanTrashBin(w http.ResponseWriter, r *http.Request) {
|
|
|
//Get and check user permission
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
@@ -1000,7 +1000,7 @@ func system_fs_WebSocketScanTrashBin(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-//Scan all the directory and get trash files within the system
|
|
|
+// Scan all the directory and get trash files within the system
|
|
|
func system_fs_scanTrashBin(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -1053,7 +1053,7 @@ func system_fs_scanTrashBin(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendJSONResponse(w, string(jsonString))
|
|
|
}
|
|
|
|
|
|
-//Restore a trashed file to its parent dir
|
|
|
+// Restore a trashed file to its parent dir
|
|
|
func system_fs_restoreFile(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -1103,7 +1103,7 @@ func system_fs_restoreFile(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendOK(w)
|
|
|
}
|
|
|
|
|
|
-//Clear all trashed file in the system
|
|
|
+// Clear all trashed file in the system
|
|
|
func system_fs_clearTrashBin(w http.ResponseWriter, r *http.Request) {
|
|
|
u, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -1138,7 +1138,7 @@ func system_fs_clearTrashBin(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendOK(w)
|
|
|
}
|
|
|
|
|
|
-//Get all trash in a string list
|
|
|
+// Get all trash in a string list
|
|
|
func system_fs_listTrash(username string) ([]string, []*filesystem.FileSystemHandler, error) {
|
|
|
userinfo, _ := userHandler.GetUserInfoFromUsername(username)
|
|
|
scanningRoots := []*filesystem.FileSystemHandler{}
|
|
@@ -2114,7 +2114,7 @@ func system_fs_handleOpr(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendOK(w)
|
|
|
}
|
|
|
|
|
|
-//Allow systems to store key value pairs in the database as preferences.
|
|
|
+// Allow systems to store key value pairs in the database as preferences.
|
|
|
func system_fs_handleUserPreference(w http.ResponseWriter, r *http.Request) {
|
|
|
username, err := authAgent.GetUserName(w, r)
|
|
|
if err != nil {
|
|
@@ -2327,7 +2327,7 @@ func system_fs_specialURIEncode(inputPath string) string {
|
|
|
return inputPath
|
|
|
}
|
|
|
|
|
|
-//Handle file properties request
|
|
|
+// Handle file properties request
|
|
|
func system_fs_getFileProperties(w http.ResponseWriter, r *http.Request) {
|
|
|
type fileProperties struct {
|
|
|
VirtualPath string
|
|
@@ -2592,7 +2592,7 @@ func system_fs_handleList(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-//Handle getting a hash from a given contents in the given path
|
|
|
+// Handle getting a hash from a given contents in the given path
|
|
|
func system_fs_handleDirHash(w http.ResponseWriter, r *http.Request) {
|
|
|
currentDir, err := utils.GetPara(r, "dir")
|
|
|
if err != nil {
|
|
@@ -2664,7 +2664,7 @@ func system_fs_handleDirHash(w http.ResponseWriter, r *http.Request) {
|
|
|
File zipping and unzipping functions
|
|
|
*/
|
|
|
|
|
|
-//Handle all zip related API
|
|
|
+// Handle all zip related API
|
|
|
func system_fs_zipHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -2781,7 +2781,7 @@ func system_fs_zipHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
cleanFsBufferFileFromList(realSourcePaths)
|
|
|
}
|
|
|
|
|
|
-//Manage file version history
|
|
|
+// Manage file version history
|
|
|
func system_fs_FileVersionHistory(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -2888,7 +2888,7 @@ func system_fs_clearVersionHistories() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//Handle cache rendering with websocket pipeline
|
|
|
+// Handle cache rendering with websocket pipeline
|
|
|
func system_fs_handleCacheRender(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, _ := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
vpath, err := utils.GetPara(r, "folder")
|
|
@@ -2915,7 +2915,7 @@ func system_fs_handleCacheRender(w http.ResponseWriter, r *http.Request) {
|
|
|
thumbRenderHandler.HandleLoadCache(w, r, fsh, rpath, sortMode)
|
|
|
}
|
|
|
|
|
|
-//Handle loading of one thumbnail
|
|
|
+// Handle loading of one thumbnail
|
|
|
func system_fs_handleThumbnailLoad(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, _ := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
vpath, err := utils.GetPara(r, "vpath")
|
|
@@ -2966,7 +2966,7 @@ func system_fs_handleThumbnailLoad(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//Handle file thumbnail caching
|
|
|
+// Handle file thumbnail caching
|
|
|
func system_fs_handleFolderCache(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, _ := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
vfolderpath, err := utils.GetPara(r, "folder")
|
|
@@ -2985,7 +2985,7 @@ func system_fs_handleFolderCache(w http.ResponseWriter, r *http.Request) {
|
|
|
utils.SendOK(w)
|
|
|
}
|
|
|
|
|
|
-//Handle the get and set of sort mode of a particular folder
|
|
|
+// Handle the get and set of sort mode of a particular folder
|
|
|
func system_fs_handleFolderSortModePreference(w http.ResponseWriter, r *http.Request) {
|
|
|
userinfo, err := userHandler.GetUserInfoFromRequest(w, r)
|
|
|
if err != nil {
|
|
@@ -3034,7 +3034,7 @@ func system_fs_handleFolderSortModePreference(w http.ResponseWriter, r *http.Req
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//Handle setting and loading of file permission on Linux
|
|
|
+// Handle setting and loading of file permission on Linux
|
|
|
func system_fs_handleFilePermission(w http.ResponseWriter, r *http.Request) {
|
|
|
file, err := utils.PostPara(r, "file")
|
|
|
if err != nil {
|
|
@@ -3122,7 +3122,7 @@ func system_fs_handleFilePermission(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//Clear the old files inside the tmp file
|
|
|
+// Clear the old files inside the tmp file
|
|
|
func system_fs_clearOldTmpFiles() {
|
|
|
filesToBeDelete := []string{}
|
|
|
tmpAbs, _ := filepath.Abs(*tmp_directory)
|
|
@@ -3183,7 +3183,7 @@ func system_fs_clearOldTmpFiles() {
|
|
|
|
|
|
*/
|
|
|
|
|
|
-//Generate a random buffer filepath. Remember to delete file after usage
|
|
|
+// Generate a random buffer filepath. Remember to delete file after usage
|
|
|
func getFsBufferFilepath(originalFilename string, keepOriginalName bool) string {
|
|
|
thisBuffFilename := uuid.NewV4().String()
|
|
|
tmpDir := filepath.Join(*tmp_directory, "fsBuff")
|
|
@@ -3196,7 +3196,7 @@ func getFsBufferFilepath(originalFilename string, keepOriginalName bool) string
|
|
|
return filepath.ToSlash(targetFile)
|
|
|
}
|
|
|
|
|
|
-//Generate a buffer filepath and buffer the remote file to local. Remember to remove file after done.
|
|
|
+// Generate a buffer filepath and buffer the remote file to local. Remember to remove file after done.
|
|
|
func bufferRemoteFileToLocal(targetFsh *filesystem.FileSystemHandler, rpath string, keepOriginalName bool) (string, error) {
|
|
|
newBufferFilename := getFsBufferFilepath(rpath, keepOriginalName)
|
|
|
src, err := targetFsh.FileSystemAbstraction.ReadStream(rpath)
|
|
@@ -3217,7 +3217,7 @@ func bufferRemoteFileToLocal(targetFsh *filesystem.FileSystemHandler, rpath stri
|
|
|
return newBufferFilename, nil
|
|
|
}
|
|
|
|
|
|
-//Check if a file is buffer filepath
|
|
|
+// Check if a file is buffer filepath
|
|
|
func isFsBufferFilepath(filename string) bool {
|
|
|
tmpDir := filepath.Join(*tmp_directory, "fsBuff")
|
|
|
filenameAbs, _ := filepath.Abs(filename)
|