summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2019-01-29 11:40:45 +0100
committerBackportbot <backportbot-noreply@rullzer.com>2019-01-29 14:47:46 +0000
commit6fb6f3872e0f873d2e9bc695fd31ace4db8c66ab (patch)
tree843a3ac783ed95df4c59ec298335dd01aeba40a8 /apps
parentc66f93ad58cf185ad1e4c01ece23f742c65ae297 (diff)
downloadnextcloud-server-6fb6f3872e0f873d2e9bc695fd31ace4db8c66ab.tar.gz
nextcloud-server-6fb6f3872e0f873d2e9bc695fd31ace4db8c66ab.zip
Fix dropping a folder on a folder row
When the uploaded files have a relative path (that is, when a folder is uploaded) it is first ensured that all the parent folders exist, which is done by trying to create them. When a folder is created in the currently opened folder the file list is updated and a row for the new folder is added. However, this was done too when the folder already existed, which caused the previous row to be removed and a new one added to replace it. For security reasons, some special headers need to be set in requests; this is done automatically for jQuery by handling the "ajaxSend" event in the document. In the case of DAV requests, if the headers are not set the server rejects the request with "CSRF check not passed". When a file or folder is dropped on a folder row the jQuery upload events are chained from the initial drop event, which has the row as its target. In order to upload the file jQuery performs a request, which triggers the "ajaxSend" event in the row; this event then bubbles up to the document, which is then handled by adding the special headers to the request. However, when a folder was dropped on a folder row that folder row was removed when ensuring that the folder exists. The jQuery upload events were still triggered on the row, but as it had been removed it had no parent nodes, and thus the events did not bubble up. Due to this the "ajaxSend" event never reached the document when triggered on the removed row, the headers were not set, and the upload failed. All this is simply fixed by not removing the folder row when trying to create it if it existed already. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/file-upload.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 9c1e2df53a0..31577e9a76b 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -516,7 +516,9 @@ OC.Uploader.prototype = _.extend({
self.filesClient.createDirectory(fullPath).always(function(status) {
// 405 is expected if the folder already exists
if ((status >= 200 && status < 300) || status === 405) {
- self.trigger('createdfolder', fullPath);
+ if (status !== 405) {
+ self.trigger('createdfolder', fullPath);
+ }
deferred.resolve();
return;
}