Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty directory drag-and-drop in Files UI #29592

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
16 changes: 13 additions & 3 deletions apps/files/js/jquery.fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,12 @@
} else {
paramNameSet = paramName;
}
data.originalFiles = files;
data.originalFiles = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, I knew that one needed to hack the library! good to see that the browsers do support empty folders

$.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];
Expand Down Expand Up @@ -1098,7 +1103,12 @@
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 () {
Expand Down Expand Up @@ -1486,4 +1496,4 @@

});

}));
}));