Browse Source

Fixed huge file cutoff size calculation error bug in File Manager

TC pushbot 5 2 years ago
parent
commit
6aba5578d7

+ 10 - 0
disk.go

@@ -30,12 +30,22 @@ func DiskServiceInit() {
 		},
 	})
 
+	//Anyone logged in can load router
+	authRouter := prout.NewModuleRouter(prout.RouterOption{
+		AdminOnly:   false,
+		UserHandler: userHandler,
+		DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
+			utils.SendErrorResponse(w, "Permission Denied")
+		},
+	})
+
 	//Disk Space Display endpoint
 	router.HandleFunc("/system/disk/space/list", diskspace.HandleDiskSpaceList)
 
 	//Handle Virtual Disk Properties display endpoints
 	dc := diskcapacity.NewCapacityResolver(userHandler)
 	router.HandleFunc("/system/disk/space/resolve", dc.HandleCapacityResolving)
+	authRouter.HandleFunc("/system/disk/space/tmp", dc.HandleTmpCapacityResolving)
 
 	//New Large File Scanner
 	lfs := sortfile.NewLargeFileScanner(userHandler)

+ 14 - 1
mod/disk/diskcapacity/diskcapacity.go

@@ -32,7 +32,7 @@ type CapacityInfo struct {
 	Total             int64
 }
 
-//Create a new Capacity Resolver with the given user handler
+// Create a new Capacity Resolver with the given user handler
 func NewCapacityResolver(u *user.UserHandler) *Resolver {
 	return &Resolver{
 		UserHandler: u,
@@ -71,7 +71,20 @@ func (cr *Resolver) HandleCapacityResolving(w http.ResponseWriter, r *http.Reque
 	//Send the requested path capacity information
 	js, _ := json.Marshal(capinfo)
 	utils.SendJSONResponse(w, string(js))
+}
+
+// Get the capacity in tmp folder, accessible by everyone by default
+func (cr *Resolver) HandleTmpCapacityResolving(w http.ResponseWriter, r *http.Request) {
+	//Check if the request user is authenticated
+	userinfo, err := cr.UserHandler.GetUserInfoFromRequest(w, r)
+	if err != nil {
+		utils.SendErrorResponse(w, "User not logged in")
+		return
+	}
 
+	capinfo, _ := cr.ResolveCapacityInfo(userinfo.Username, "tmp:/")
+	js, _ := json.Marshal(capinfo)
+	utils.SendJSONResponse(w, string(js))
 }
 
 func (cr *Resolver) ResolveCapacityInfo(username string, vpath string) (*CapacityInfo, error) {

+ 3 - 1
system.info.go

@@ -75,7 +75,9 @@ func SystemInfoInit() {
 		router.HandleFunc("/system/info/ifconfig", info.Ifconfig)
 		router.HandleFunc("/system/info/getDriveStat", info.GetDriveStat)
 		router.HandleFunc("/system/info/usbPorts", info.GetUSB)
-		router.HandleFunc("/system/info/getRAMinfo", info.GetRamInfo)
+
+		//For low-memory mode detection
+		authRouter.HandleFunc("/system/info/getRAMinfo", info.GetRamInfo)
 
 		//Register as a system setting
 		registerSetting(settingModule{

+ 7 - 7
web/SystemAO/file_system/file_explorer.html

@@ -4706,17 +4706,17 @@
 
             //Get the avaible space on tmp disk and decide the cutoff file size that need to directly write to disk
             $.ajax({
-                url: "../../system/disk/space/resolve",
+                url: "../../system/disk/space/tmp",
                 method: "POST",
-                data: {path: "tmp:/"},
+                data: {},
                 success: function(data){
                     if (data.error !== undefined){
-                      
+                        console.log("[File Explorer] Unable to auto-detect huge file cutoff size: " + data.error);
                     }else{
-                        if (!isNaN(data.Avilable) && data.Avilable > 0){
-                            largeFileCutoffSize = data.Avilable/16 - 4096;
-                            console.log("[File Explorer] Setting huge file cutoff size at: " + ao_module_utils.formatBytes(data.Avilable/16));
-                        }else if (isNaN(data.Avilable)){
+                        if (!isNaN(data.Available) && data.Available > 0){
+                            largeFileCutoffSize = data.Available/16 - 4096;
+                            console.log("[File Explorer] Setting huge file cutoff size at: " + ao_module_utils.formatBytes(data.Available/16));
+                        }else if (isNaN(data.Available)){
                             console.log("[File Explorer] Unable to read available tmp disk size. Using default huge file cutoff size.");
                         }
                         

+ 0 - 164
web/SystemAO/info/gomod-license.csv

@@ -1,164 +0,0 @@
-cloud.google.com/go/compute/metadata,https://github.com/googleapis/google-cloud-go/blob/compute/v1.9.0/compute/LICENSE,Apache-2.0
-github.com/Microsoft/go-winio,https://github.com/Microsoft/go-winio/blob/v0.5.2/LICENSE,MIT
-github.com/ProtonMail/go-crypto,https://github.com/ProtonMail/go-crypto/blob/4b6e5c587895/LICENSE,BSD-3-Clause
-github.com/andybalholm/brotli,https://github.com/andybalholm/brotli/blob/v1.0.4/LICENSE,MIT
-github.com/boltdb/bolt,https://github.com/boltdb/bolt/blob/v1.3.1/LICENSE,MIT
-github.com/cenkalti/backoff,https://github.com/cenkalti/backoff/blob/v2.2.1/LICENSE,MIT
-github.com/cloudflare/circl,https://github.com/cloudflare/circl/blob/v1.2.0/LICENSE,BSD-3-Clause
-github.com/dhowden/tag,https://github.com/dhowden/tag/blob/adf36e896086/LICENSE,BSD-2-Clause
-github.com/disintegration/imaging,https://github.com/disintegration/imaging/blob/v1.6.2/LICENSE,MIT
-github.com/dsnet/compress,https://github.com/dsnet/compress/blob/f66993602bf5/LICENSE.md,BSD-3-Clause
-github.com/emirpasic/gods,https://github.com/emirpasic/gods/blob/v1.18.1/LICENSE,BSD-2-Clause
-github.com/fclairamb/ftpserverlib,https://github.com/fclairamb/ftpserverlib/blob/v0.19.1/license.txt,MIT
-github.com/fclairamb/go-log,https://github.com/fclairamb/go-log/blob/v0.4.1/license.txt,MIT
-github.com/fogleman/fauxgl,https://github.com/fogleman/fauxgl/blob/27cddc103802/LICENSE.md,MIT
-github.com/fogleman/simplify,https://github.com/fogleman/simplify/blob/d32f302d5046/LICENSE.md,MIT
-github.com/gabriel-vasile/mimetype,https://github.com/gabriel-vasile/mimetype/blob/v1.4.1/LICENSE,MIT
-github.com/geoffgarside/ber,https://github.com/geoffgarside/ber/blob/v1.1.0/LICENSE,BSD-3-Clause
-github.com/go-git/gcfg,https://github.com/go-git/gcfg/blob/v1.5.0/LICENSE,BSD-3-Clause
-github.com/go-git/go-billy/v5,https://github.com/go-git/go-billy/blob/v5.3.1/LICENSE,Apache-2.0
-github.com/go-git/go-git/v5,https://github.com/go-git/go-git/blob/v5.4.2/LICENSE,Apache-2.0
-github.com/go-ldap/ldap,https://github.com/go-ldap/ldap/blob/v3.0.3/LICENSE,MIT
-github.com/golang/freetype,Unknown,Unknown
-github.com/golang/freetype/raster,Unknown,Unknown
-github.com/golang/freetype/truetype,Unknown,Unknown
-github.com/golang/snappy,https://github.com/golang/snappy/blob/v0.0.4/LICENSE,BSD-3-Clause
-github.com/google/uuid,https://github.com/google/uuid/blob/v1.3.0/LICENSE,BSD-3-Clause
-github.com/gorilla/securecookie,https://github.com/gorilla/securecookie/blob/v1.1.1/LICENSE,BSD-3-Clause
-github.com/gorilla/sessions,https://github.com/gorilla/sessions/blob/v1.2.1/LICENSE,BSD-3-Clause
-github.com/gorilla/websocket,https://github.com/gorilla/websocket/blob/v1.5.0/LICENSE,BSD-2-Clause
-github.com/grandcat/zeroconf,https://github.com/grandcat/zeroconf/blob/v1.0.0/LICENSE,MIT
-github.com/hashicorp/errwrap,https://github.com/hashicorp/errwrap/blob/v1.1.0/LICENSE,MPL-2.0
-github.com/hashicorp/go-multierror,https://github.com/hashicorp/go-multierror/blob/v1.1.1/LICENSE,MPL-2.0
-github.com/hirochachacha/go-smb2,https://github.com/hirochachacha/go-smb2/blob/v1.1.0/LICENSE,BSD-2-Clause
-github.com/imdario/mergo,https://github.com/imdario/mergo/blob/v0.3.13/LICENSE,BSD-3-Clause
-github.com/jbenet/go-context/io,https://github.com/jbenet/go-context/blob/d14ea06fba99/LICENSE,MIT
-github.com/jlaffaye/ftp,https://github.com/jlaffaye/ftp/blob/v0.1.0/LICENSE,ISC
-github.com/kevinburke/ssh_config,https://github.com/kevinburke/ssh_config/blob/v1.2.0/LICENSE,MIT
-github.com/klauspost/compress,https://github.com/klauspost/compress/blob/v1.15.9/LICENSE,Apache-2.0
-github.com/klauspost/compress/internal/snapref,https://github.com/klauspost/compress/blob/v1.15.9/internal\snapref\LICENSE,BSD-3-Clause
-github.com/klauspost/compress/zstd/internal/xxhash,https://github.com/klauspost/compress/blob/v1.15.9/zstd\internal\xxhash\LICENSE.txt,MIT
-github.com/klauspost/pgzip,https://github.com/klauspost/pgzip/blob/v1.2.5/LICENSE,MIT
-github.com/koron/go-ssdp,https://github.com/koron/go-ssdp/blob/v0.0.3/LICENSE,MIT
-github.com/kr/fs,https://github.com/kr/fs/blob/v0.1.0/LICENSE,BSD-3-Clause
-github.com/mholt/archiver/v3,https://github.com/mholt/archiver/blob/v3.5.1/LICENSE,MIT
-github.com/miekg/dns,https://github.com/miekg/dns/blob/v1.1.50/LICENSE,BSD-3-Clause
-github.com/mitchellh/go-homedir,https://github.com/mitchellh/go-homedir/blob/v1.1.0/LICENSE,MIT
-github.com/nfnt/resize,https://github.com/nfnt/resize/blob/83c6a9932646/LICENSE,ISC
-github.com/nwaples/rardecode,https://github.com/nwaples/rardecode/blob/v1.1.3/LICENSE,BSD-2-Clause
-github.com/oliamb/cutter,https://github.com/oliamb/cutter/blob/v0.2.2/LICENSE,MIT
-github.com/oov/psd,https://github.com/oov/psd/blob/5db5eafcecbb/LICENSE,MIT
-github.com/pierrec/lz4/v4,https://github.com/pierrec/lz4/blob/v4.1.15/LICENSE,BSD-3-Clause
-github.com/pkg/sftp,https://github.com/pkg/sftp/blob/v1.13.5/LICENSE,BSD-2-Clause
-github.com/robertkrimen/otto,https://github.com/robertkrimen/otto/blob/b87d35c0b86f/LICENSE,MIT
-github.com/satori/go.uuid,https://github.com/satori/go.uuid/blob/v1.2.0/LICENSE,MIT
-github.com/sergi/go-diff/diffmatchpatch,https://github.com/sergi/go-diff/blob/v1.2.0/LICENSE,MIT
-github.com/spf13/afero,https://github.com/spf13/afero/blob/v1.9.2/LICENSE.txt,Apache-2.0
-github.com/studio-b12/gowebdav,https://github.com/studio-b12/gowebdav/blob/c7b1ff8a5e62/LICENSE,BSD-3-Clause
-github.com/tidwall/pretty,https://github.com/tidwall/pretty/blob/v1.2.0/LICENSE,MIT
-github.com/ulikunitz/xz,https://github.com/ulikunitz/xz/blob/v0.5.10/LICENSE,BSD-3-Clause
-github.com/valyala/bytebufferpool,https://github.com/valyala/bytebufferpool/blob/v1.0.0/LICENSE,MIT
-github.com/valyala/fasttemplate,https://github.com/valyala/fasttemplate/blob/v1.2.1/LICENSE,MIT
-github.com/xanzy/ssh-agent,https://github.com/xanzy/ssh-agent/blob/v0.3.2/LICENSE,Apache-2.0
-github.com/xi2/xz,Unknown,Unknown
-gitlab.com/NebulousLabs/fastrand,https://gitlab.com/NebulousLabs/fastrand/blob/603482d69e40/LICENSE,MIT
-gitlab.com/NebulousLabs/go-upnp,https://gitlab.com/NebulousLabs/go-upnp/blob/11da932010b6/LICENSE,MIT
-gitlab.com/NebulousLabs/go-upnp/goupnp,https://gitlab.com/NebulousLabs/go-upnp/blob/11da932010b6/goupnp\LICENSE,BSD-2-Clause
-golang.org/x/crypto,https://cs.opensource.google/go/x/crypto/+/v0.3.0:LICENSE,BSD-3-Clause
-golang.org/x/image,https://cs.opensource.google/go/x/image/+/e7cb9697:LICENSE,BSD-3-Clause
-golang.org/x/net,https://cs.opensource.google/go/x/net/+/v0.2.0:LICENSE,BSD-3-Clause
-golang.org/x/oauth2,https://cs.opensource.google/go/x/oauth2/+/0ebed06d:LICENSE,BSD-3-Clause
-golang.org/x/sync/syncmap,https://cs.opensource.google/go/x/sync/+/7fc1605a:LICENSE,BSD-3-Clause
-golang.org/x/sys,https://cs.opensource.google/go/x/sys/+/v0.2.0:LICENSE,BSD-3-Clause
-golang.org/x/text,https://cs.opensource.google/go/x/text/+/v0.4.0:LICENSE,BSD-3-Clause
-gopkg.in/asn1-ber.v1,https://github.com/go-asn1-ber/asn1-ber/blob/f715ec2f112d/LICENSE,MIT
-gopkg.in/sourcemap.v1,https://github.com/go-sourcemap/sourcemap/blob/v1.0.5/LICENSE,BSD-2-Clause
-gopkg.in/warnings.v0,https://github.com/go-warnings/warnings/blob/v0.1.2/LICENSE,BSD-2-Clause
-imuslab.com/arozos,Unknown,Unknown
-imuslab.com/arozos/mod/agi,Unknown,Unknown
-imuslab.com/arozos/mod/apt,Unknown,Unknown
-imuslab.com/arozos/mod/auth,Unknown,Unknown
-imuslab.com/arozos/mod/auth/accesscontrol,Unknown,Unknown
-imuslab.com/arozos/mod/auth/accesscontrol/blacklist,Unknown,Unknown
-imuslab.com/arozos/mod/auth/accesscontrol/whitelist,Unknown,Unknown
-imuslab.com/arozos/mod/auth/authlogger,Unknown,Unknown
-imuslab.com/arozos/mod/auth/autologin,Unknown,Unknown
-imuslab.com/arozos/mod/auth/explogin,Unknown,Unknown
-imuslab.com/arozos/mod/auth/ldap,Unknown,Unknown
-imuslab.com/arozos/mod/auth/ldap/ldapreader,Unknown,Unknown
-imuslab.com/arozos/mod/auth/oauth2,Unknown,Unknown
-imuslab.com/arozos/mod/auth/oauth2/syncdb,Unknown,Unknown
-imuslab.com/arozos/mod/auth/register,Unknown,Unknown
-imuslab.com/arozos/mod/cluster/wakeonlan,Unknown,Unknown
-imuslab.com/arozos/mod/compatibility,Unknown,Unknown
-imuslab.com/arozos/mod/console,Unknown,Unknown
-imuslab.com/arozos/mod/database,Unknown,Unknown
-imuslab.com/arozos/mod/disk/diskcapacity,Unknown,Unknown
-imuslab.com/arozos/mod/disk/diskcapacity/dftool,Unknown,Unknown
-imuslab.com/arozos/mod/disk/diskmg,Unknown,Unknown
-imuslab.com/arozos/mod/disk/diskspace,Unknown,Unknown
-imuslab.com/arozos/mod/disk/smart,Unknown,Unknown
-imuslab.com/arozos/mod/disk/sortfile,Unknown,Unknown
-imuslab.com/arozos/mod/fileservers,Unknown,Unknown
-imuslab.com/arozos/mod/fileservers/servers/dirserv,Unknown,Unknown
-imuslab.com/arozos/mod/fileservers/servers/ftpserv,Unknown,Unknown
-imuslab.com/arozos/mod/fileservers/servers/sftpserv,Unknown,Unknown
-imuslab.com/arozos/mod/fileservers/servers/webdavserv,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/abstractions/ftpfs,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/abstractions/localfs,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/abstractions/sftpfs,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/abstractions/smbfs,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/abstractions/webdavfs,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/arozfs,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/fspermission,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/fssort,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/fuzzy,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/hidden,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/localversion,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/metadata,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/renderer,Unknown,Unknown
-imuslab.com/arozos/mod/filesystem/shortcut,Unknown,Unknown
-imuslab.com/arozos/mod/info/hardwareinfo,Unknown,Unknown
-imuslab.com/arozos/mod/info/logger,Unknown,Unknown
-imuslab.com/arozos/mod/info/logviewer,Unknown,Unknown
-imuslab.com/arozos/mod/info/usageinfo,Unknown,Unknown
-imuslab.com/arozos/mod/iot,Unknown,Unknown
-imuslab.com/arozos/mod/iot/hds,Unknown,Unknown
-imuslab.com/arozos/mod/iot/hdsv2,Unknown,Unknown
-imuslab.com/arozos/mod/iot/sonoff_s2x,Unknown,Unknown
-imuslab.com/arozos/mod/modules,Unknown,Unknown
-imuslab.com/arozos/mod/network,Unknown,Unknown
-imuslab.com/arozos/mod/network/gzipmiddleware,Unknown,Unknown
-imuslab.com/arozos/mod/network/mdns,Unknown,Unknown
-imuslab.com/arozos/mod/network/neighbour,Unknown,Unknown
-imuslab.com/arozos/mod/network/netstat,Unknown,Unknown
-imuslab.com/arozos/mod/network/reverseproxy,Unknown,MIT
-imuslab.com/arozos/mod/network/ssdp,Unknown,Unknown
-imuslab.com/arozos/mod/network/upnp,Unknown,Unknown
-imuslab.com/arozos/mod/network/webdav,Unknown,BSD-3-Clause
-imuslab.com/arozos/mod/network/websocket,Unknown,Unknown
-imuslab.com/arozos/mod/network/websocketproxy,Unknown,MIT
-imuslab.com/arozos/mod/network/wifi,Unknown,Unknown
-imuslab.com/arozos/mod/neuralnet,Unknown,Unknown
-imuslab.com/arozos/mod/notification,Unknown,Unknown
-imuslab.com/arozos/mod/notification/agents/smtpn,Unknown,Unknown
-imuslab.com/arozos/mod/permission,Unknown,Unknown
-imuslab.com/arozos/mod/prouter,Unknown,Unknown
-imuslab.com/arozos/mod/quota,Unknown,Unknown
-imuslab.com/arozos/mod/security/csrf,Unknown,Unknown
-imuslab.com/arozos/mod/share,Unknown,Unknown
-imuslab.com/arozos/mod/share/shareEntry,Unknown,Unknown
-imuslab.com/arozos/mod/storage,Unknown,Unknown
-imuslab.com/arozos/mod/storage/bridge,Unknown,Unknown
-imuslab.com/arozos/mod/storage/du,Unknown,Unknown
-imuslab.com/arozos/mod/storage/ftp,Unknown,Unknown
-imuslab.com/arozos/mod/storage/sftpserver,Unknown,Unknown
-imuslab.com/arozos/mod/storage/webdav,Unknown,Unknown
-imuslab.com/arozos/mod/subservice,Unknown,Unknown
-imuslab.com/arozos/mod/time/nightly,Unknown,Unknown
-imuslab.com/arozos/mod/time/scheduler,Unknown,Unknown
-imuslab.com/arozos/mod/updates,Unknown,Unknown
-imuslab.com/arozos/mod/user,Unknown,Unknown
-imuslab.com/arozos/mod/utils,Unknown,Unknown
-imuslab.com/arozos/mod/www,Unknown,Unknown

+ 1 - 1
web/desktop.system

@@ -6239,7 +6239,7 @@
                         //Permission denied or other reasons that cannot access harwdare info. Use default mode
                         lowMemoryMode = true;
                     }else{
-                        //Check if ramsize > 1.8 GB (2GB). If yes, switch to large memory upload mode
+                        //Check if ramsize > 3.8 GB (4GB). If yes, switch to large memory upload mode
                         var memsize = JSON.parse(data);
                         if (parseFloat(memsize)/ 1024 / 1024 / 1024 >= 3.8){
                             console.log("%c[Desktop] Setting upload mode to large memory mode", 'color: #2ba16e');