Skip to content

Commit 7b72b13

Browse files
pjftskjnldsv
andcommitted
Fix bug introduced on drag and drop external files
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æ <[email protected]> Signed-off-by: pjft <[email protected]>
1 parent 5fd9ce9 commit 7b72b13

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

apps/files/js/file-upload.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,10 @@ OC.Uploader.prototype = _.extend({
776776
// no list to check against
777777
return true;
778778
}
779+
if (upload.getTargetFolder() != fileList.getCurrentDirectory()) {
780+
// not uploading to the current folder
781+
return true;
782+
}
779783
var fileInfo = fileList.findFile(file.name);
780784
if (fileInfo) {
781785
conflicts.push([
@@ -997,7 +1001,8 @@ OC.Uploader.prototype = _.extend({
9971001
freeSpace = $('#free_space').val()
9981002
} else if (upload.getTargetFolder().indexOf(self.fileList.getCurrentDirectory()) === 0) {
9991003
// Check subdirectory free space if file is uploaded there
1000-
var targetSubdir = upload._targetFolder.replace(self.fileList.getCurrentDirectory(), '')
1004+
// Retrieve the folder destination name
1005+
var targetSubdir = upload._targetFolder.split('/').pop()
10011006
freeSpace = parseInt(upload.uploader.fileList.getModelForFile(targetSubdir).get('quotaAvailableBytes'))
10021007
}
10031008
if (freeSpace >= 0 && selection.totalBytes > freeSpace) {

0 commit comments

Comments
 (0)