|
@@ -534,12 +534,19 @@ func system_fs_handleUpload(w http.ResponseWriter, r *http.Request) {
|
|
if usedRam > 0 && totalRam > 0 {
|
|
if usedRam > 0 && totalRam > 0 {
|
|
//Do not use all RAM. Use only 80% of it
|
|
//Do not use all RAM. Use only 80% of it
|
|
totalRam = int64(float64(totalRam) * 0.8)
|
|
totalRam = int64(float64(totalRam) * 0.8)
|
|
- autoCalculatedUploadBuf = ((totalRam-usedRam-systemReservedUploadMem)/2)/1048576 - 12 //12 MB as max memory overflow buffer
|
|
|
|
- systemReservedUploadMem += (autoCalculatedUploadBuf + 12)
|
|
|
|
|
|
+
|
|
|
|
+ //Use *upload_buf per 1GB rules for upload
|
|
|
|
+ usableMemorySpace := totalRam - usedRam - systemReservedUploadMem
|
|
|
|
+ autoCalculatedUploadBuf := (usableMemorySpace / (1024 * 1024 * 1024)) * int64(*upload_buf)
|
|
|
|
+
|
|
|
|
+ //Add the reserve to global reserve memory value
|
|
|
|
+ systemReservedUploadMem += autoCalculatedUploadBuf
|
|
|
|
+
|
|
|
|
+ //Handle file upload
|
|
log.Println("*Testing* Upload buffer set to ", autoCalculatedUploadBuf, "MB")
|
|
log.Println("*Testing* Upload buffer set to ", autoCalculatedUploadBuf, "MB")
|
|
err = r.ParseMultipartForm(int64(autoCalculatedUploadBuf) << 20)
|
|
err = r.ParseMultipartForm(int64(autoCalculatedUploadBuf) << 20)
|
|
} else {
|
|
} else {
|
|
- //Unable to get RAM usage. Use default parser
|
|
|
|
|
|
+ //Unable to get RAM usage. Use default parser buffer size
|
|
err = r.ParseMultipartForm(int64(*upload_buf) << 20)
|
|
err = r.ParseMultipartForm(int64(*upload_buf) << 20)
|
|
}
|
|
}
|
|
|
|
|