]> source.dussan.org Git - nextcloud-server.git/commitdiff
refs #11864 handle empty dir drop in Files UI 29596/head
authorJulien Veyssier <eneiluj@posteo.net>
Mon, 8 Nov 2021 11:22:57 +0000 (12:22 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 8 Nov 2021 17:18:51 +0000 (17:18 +0000)
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
apps/files/js/file-upload.js
apps/files/js/jquery.fileupload.js

index 672fc1d770b38ab4009d65cabcf8c959a4661826..7ab88ed61bdbd4f877080346817e5f736954742f 100644 (file)
@@ -215,6 +215,12 @@ OC.FileUpload.prototype = {
                var data = this.data;
                var file = this.getFile();
 
+               // if file is a directory, just create it
+               // files are handled separately
+               if (file.isDirectory) {
+                       return this.uploader.ensureFolderExists(OC.joinPaths(this._targetFolder, file.fullPath));
+               }
+
                if (self.aborted === true) {
                        return $.Deferred().resolve().promise();
                }
index ea8529f322620218664475d889ab0797032fcb63..cc0c97ba3edeb5000d10cab05b6fe937041f4e20 100644 (file)
             } else {
                 paramNameSet = paramName;
             }
-            data.originalFiles = files;
+            data.originalFiles = [];
+            $.each(files, function (file) {
+                if (!file.isDirectory) {
+                    data.originalFiles.push(file);
+                }
+            });
             $.each(fileSet || files, function (index, element) {
                 var newData = $.extend({}, data);
                 newData.files = fileSet ? element : [element];
                         entries,
                         path + entry.name + '/'
                     ).done(function (files) {
-                        dfd.resolve(files);
+                        // empty folder
+                        if (!files.length && entry.isDirectory) {
+                            dfd.resolve(entry);
+                        } else {
+                            dfd.resolve(files);
+                        }
                     }).fail(errorHandler);
                 },
                 readEntries = function () {
 
     });
 
-}));
\ No newline at end of file
+}));