瀏覽代碼

Fixed mobile theme color bug, added image render too large bypass and updated to v2.010

TC pushbot 5 2 年之前
父節點
當前提交
1f6f65ff9e
共有 5 個文件被更改,包括 47 次插入36 次删除
  1. 31 31
      file_system.go
  2. 2 1
      main.flags.go
  3. 8 1
      mod/filesystem/metadata/image.go
  4. 1 0
      subservice/ArSamba
  5. 5 3
      web/mobile.system

+ 31 - 31
file_system.go

@@ -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)

+ 2 - 1
main.flags.go

@@ -29,7 +29,7 @@ var subserviceBasePort = 12810            //Next subservice port
 
 // =========== SYSTEM BUILD INFORMATION ==============
 var build_version = "development"                      //System build flag, this can be either {development / production / stable}
-var internal_version = "0.2.009"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
+var internal_version = "0.2.010"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
 var deviceUUID string                                  //The device uuid of this host
 var deviceVendor = "IMUSLAB.INC"                       //Vendor of the system
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information
@@ -57,6 +57,7 @@ var disable_subservices = flag.Bool("disable_subservice", false, "Disable subser
 var allow_upnp = flag.Bool("allow_upnp", false, "Enable uPNP service, recommended for host under NAT router")
 var allow_ssdp = flag.Bool("allow_ssdp", true, "Enable SSDP service, disable this if you do not want your device to be scanned by Windows's Network Neighborhood Page")
 var allow_mdns = flag.Bool("allow_mdns", true, "Enable MDNS service. Allow device to be scanned by nearby ArOZ Hosts")
+var force_mac = flag.String("force_mac", "", "Force MAC address to be used for discovery services. If not set, it will use the first NIC")
 var disable_ip_resolve_services = flag.Bool("disable_ip_resolver", false, "Disable IP resolving if the system is running under reverse proxy environment")
 var enable_gzip = flag.Bool("gzip", true, "Enable gzip compress on file server")
 

+ 8 - 1
mod/filesystem/metadata/image.go

@@ -2,6 +2,7 @@ package metadata
 
 import (
 	"bytes"
+	"errors"
 	"image"
 	"image/jpeg"
 	"os"
@@ -12,7 +13,7 @@ import (
 	"imuslab.com/arozos/mod/filesystem"
 )
 
-//Generate thumbnail for image. Require real filepath
+// Generate thumbnail for image. Require real filepath
 func generateThumbnailForImage(fsh *filesystem.FileSystemHandler, cacheFolder string, file string, generateOnly bool) (string, error) {
 	if fsh.RequireBuffer {
 		return "", nil
@@ -20,6 +21,12 @@ func generateThumbnailForImage(fsh *filesystem.FileSystemHandler, cacheFolder st
 	fshAbs := fsh.FileSystemAbstraction
 	var img image.Image
 	var err error
+
+	if fshAbs.GetFileSize(file) > (25 << 20) {
+		//Maxmium image size to be converted is 25MB, on 500MB (~250MB usable) Linux System
+		//This file is too large to convert
+		return "", errors.New("image file too large")
+	}
 	if fsh.RequireBuffer {
 		//This fsh is remote. Buffer to RAM
 		imageBytes, err := fshAbs.ReadFile(file)

+ 1 - 0
subservice/ArSamba

@@ -0,0 +1 @@
+Subproject commit 429001be2e0dad995ea1b102cb05ea973da76cd7

+ 5 - 3
web/mobile.system

@@ -582,11 +582,13 @@
 
             function initUserDefinedThemeColor(){
                 $.ajax({
-                    url: "../../system/file_system/preference",
-                    data: {key: "themecolor"},
+                    url: "system/desktop/preference",
+                    data: {preference: "themecolor"},
+                    method: "POST",
                     success: function(data){
+                        console.log(data);
                         if (data.error == undefined && data != ""){
-                            $(".themeColor").css("background-color", data);
+                            setThemeColor(data);
                         }
                     }
                 });