Przeglądaj źródła

Added delete upload pending task feature and fixed filename issue during upload

Toby Chui 3 lat temu
rodzic
commit
8b34c4d8ad
2 zmienionych plików z 31 dodań i 6 usunięć
  1. 9 3
      file_system.go
  2. 22 3
      web/SystemAO/file_system/file_explorer.html

+ 9 - 3
file_system.go

@@ -413,8 +413,14 @@ func system_fs_handleLowMemoryUpload(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	//Unescape the upload target path
+	unescapedPath, err := url.PathUnescape(uploadTarget)
+	if err != nil {
+		unescapedPath = uploadTarget
+	}
+
 	//Check if the user can write to this folder
-	if !userinfo.CanWrite(uploadTarget) {
+	if !userinfo.CanWrite(unescapedPath) {
 		//No permission
 		w.WriteHeader(http.StatusForbidden)
 		w.Write([]byte("403 - Access Denied"))
@@ -422,7 +428,7 @@ func system_fs_handleLowMemoryUpload(w http.ResponseWriter, r *http.Request) {
 	}
 
 	//Translate the upload target directory
-	realUploadPath, err := userinfo.VirtualPathToRealPath(uploadTarget)
+	realUploadPath, err := userinfo.VirtualPathToRealPath(unescapedPath)
 	if err != nil {
 		w.WriteHeader(http.StatusInternalServerError)
 		w.Write([]byte("500 - Path translation failed"))
@@ -570,7 +576,7 @@ func system_fs_handleLowMemoryUpload(w http.ResponseWriter, r *http.Request) {
 	}
 
 	//Try to decode the location if possible
-	decodedUploadLocation, err := url.QueryUnescape(targetUploadLocation)
+	decodedUploadLocation, err := url.PathUnescape(targetUploadLocation)
 	if err != nil {
 		decodedUploadLocation = targetUploadLocation
 	}

+ 22 - 3
web/SystemAO/file_system/file_explorer.html

@@ -4776,6 +4776,12 @@
                 //Update all UI elements
                 updateUploadFileCount();
                 uploadingFileCount++;
+                $(".uploadTask").each(function(){
+                    if ($(this).attr("taskID") == taskUUID){
+                        //This is the target upload task object. Hide its close button
+                        $(this).find(".uploadTaskRemoveIcon").hide();
+                    }
+                });
 
                 //Start sending
                 socket.onopen = function(e) {
@@ -4880,7 +4886,6 @@
             }else{
                 /*
                     Standard Upload Mode
-                    (For host with RAM >= 2GB)
                 */
 
                 //Create the task progress Object
@@ -5216,14 +5221,28 @@
                 <div class="ts tiny primary progress" style="margin-top:-12px;">
                     <div class="bar" style="width: 0%"></div>
                 </div>
-                <div class="uploadTaskRemoveIcon" onclick="removeThisTask(this);" style="display:none;">
+                <div class="uploadTaskRemoveIcon" onclick="removeThisTask(this, '${newuuid}');" style="">
                     <i class="remove icon"></i>
                 </div>
             </div>`);
             return newuuid;
         }
 
-        function removeThisTask(object){
+        function removeThisTask(object, taskUUID){
+            //Remove item from uploadPendingList
+            let removeId = -1;
+            for (var i = 0; i < uploadPendingList.length; i++){
+                if (uploadPendingList[i].UUID == taskUUID){
+                    removeId = i;
+                    break;
+                }
+            }
+
+            if (removeId >= 0){
+                uploadPendingList.splice(removeId, 1);
+            }
+
+            //Remove the DOM Element
             $(object).parent().fadeOut('fast',
                 function(){
                     $(this).remove();