Skip to content

Commit

Permalink
Fix bug introduced on drag and drop external files
Browse files Browse the repository at this point in the history
Drag and drop of external (OS filesystem) to subdirectories in the browser would fail on specific cases, mainly when the subdirectory was no longer off the root folder.
This seemed to have been an issue introduced with the subdirectory free space calculation [here](f9536b0) and it seems to fail for any subdirectory that doesn't belong to the root folder.

Bug reports:
- https://help.nextcloud.com/t/drag-drop-into-subfolders/120731
- #24720

I couldn't find any reference on scenarios or quota management that would suggest when a subdirectory's free space would be different to the parent's free space, other than when on the root folder, where subdirectories can be external mounts.

As such, if my understanding is correct (please review), this calculation can - and should - be made by getting the free space from the first subdirectory in the total path, which caters for all subdirectory scenarios.

Please advise, happy to help improve this.

Co-authored-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Signed-off-by: pjft <paulo.j.tavares@gmail.com>
  • Loading branch information
pjft and skjnldsv committed Aug 10, 2021
1 parent 5fd9ce9 commit 95acb18
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ OC.Uploader.prototype = _.extend({
// only keep non-conflicting uploads
selection.uploads = _.filter(selection.uploads, function(upload) {
var file = upload.getFile();
if (file.relativePath) {
if (file.relativePath || upload.getTargetFolder() != fileList.getCurrentDirectory()) {
// can't check in subfolder contents
return true;
}
Expand Down Expand Up @@ -997,7 +997,8 @@ OC.Uploader.prototype = _.extend({
freeSpace = $('#free_space').val()
} else if (upload.getTargetFolder().indexOf(self.fileList.getCurrentDirectory()) === 0) {
// Check subdirectory free space if file is uploaded there
var targetSubdir = upload._targetFolder.replace(self.fileList.getCurrentDirectory(), '')
// Retrieve the folder destination name
var targetSubdir = upload._targetFolder.split('/').pop()
freeSpace = parseInt(upload.uploader.fileList.getModelForFile(targetSubdir).get('quotaAvailableBytes'))
}
if (freeSpace >= 0 && selection.totalBytes > freeSpace) {
Expand Down

0 comments on commit 95acb18

Please sign in to comment.