-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Parse Sabre Exception in OC.Files.Client and file-upload #6079
Conversation
@danxuliu Mind to help reviewing this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it would be better to add chunked uploads first and, then, add this parsing of Sabre exceptions.
@@ -900,6 +916,7 @@ OC.Uploader.prototype = _.extend({ | |||
status = upload.getResponseStatus(); | |||
} | |||
self.log('fail', e, upload); | |||
self._hideProgressBar(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When several files are uploaded at once and one of them fails this hides the progress bar before those coming after the failed one have finished. Moreover, this should not be needed anyway, as the progres bar is only shown in the fileuploadstart event, so the current _hideProgressBar
call in the fileuploadstop event should always hide it when there are no more files being uploaded, even in case of failures (in fact, the current call to _hideProgressBar
when the upload is aborted is not strictly needed, as the fileuploadstop event will be eventually triggered, but in that case it does not harm to call it there as the pending uploads will be aborted too).
Having said that... they had to have a reason to add a call to _hideProgressBar
in fail
in ownCloud, so maybe I am missing something. Thus I would left it as is in this pull request and remove it in a different one so if the progress bar happens to not be hidden in some cases then the problem can be bisected to that removed call.
var message = ''; | ||
if (upload) { | ||
var response = upload.getResponse(); | ||
message = response.message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be ensured that response
is not undefined before using it, as there is at least one (obscure...) code path in which getResponse
can return undefined
: when a chunked upload fails to create the temporary directory before uploading the file itself the upload is aborted even before it was started, so in the end this causes fail
to be called with an upload without a response. Chunked uploads do not work right now anyway, but just checking the object before using it makes no harm, and there could be other code paths that I have not found but need it too.
Also note that if the response is checked before being used, when a chunked upload fails to create the temporary directory before uploading the file itself just a message that reads abort is shown, but that is a different matter.
apps/files/js/file-upload.js
Outdated
@@ -1105,6 +1127,19 @@ OC.Uploader.prototype = _.extend({ | |||
var upload = self.getUpload(data); | |||
upload.done().then(function() { | |||
self.trigger('done', e, upload); | |||
}).fail(function(status, response) { | |||
var message = response.message; | |||
self._hideProgressBar(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above; if several files are loaded at once and the upload of the first one fails when moving the temporal assembled file of a chunked upload to its final location the progress bar would be hidden even if there are other files being uploaded.
In any case, the additions in fileuploaddone do not really belong to this commit/pull request. They are error handling code for chunked uploads (which seems to be done separately from other error handling because it handles failures in the movement of the temporal assembled file to its final destination, which is outside the standard flow of upload failures), but currently chunked uploads do not work at all (because as far as I know it should use the v2 DAV backend to use the Upload collection in the backend, and currently it uses the v1).
@danxuliu Are you open to do that? |
Yes, I have been working on it for quite some time now, but it is taking me way longer than expected :-S I hope to finish it soon, though ;-) |
7c0762f
to
e8bbc47
Compare
Codecov Report
@@ Coverage Diff @@
## master #6079 +/- ##
============================================
+ Coverage 50.74% 50.76% +0.01%
Complexity 24479 24479
============================================
Files 1581 1581
Lines 93578 93595 +17
Branches 1353 1355 +2
============================================
+ Hits 47487 47509 +22
+ Misses 46091 46086 -5
|
Now that chunked uploads have been merged I have imported again this pull request from ownCloud onto current master. Note that I have just imported the original pull request, and I have not addressed yet my own comments; I will do that later in other pull requests. |
In case of error, instead of a generic error message, an upload will display whichever message is returned in the Sabre Exception, if applicable. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
e8bbc47
to
dfc91a2
Compare
Oops, I forgot to sign the commit. Fixed now ;-) |
@danxuliu Should we try to get this in 13 or is 14 fine? |
@MorrisJobke 13, please; I "need" this merged to import more fixes for chunked uploads in Web UI. |
As far as I can see, this is ready for review, right? |
Right :-) |
@danxuliu are they points you have had your remarks on resolved? Or are they as a note? then we should turn them into issues (after merge)? |
They are not solved in this pull request, but there is no need to fill issues about them, as I am already working on fixing them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works 👍 Code makes sense
How to test:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested with files_accesscontrol, also working
I assumed that a sane message would also shown on android, but we get "unsupported media type". |
@rullzer please see above. Do you recall if you fixed this with latest antivirus update? |
yes the server throws an unsupported media type... but with a message as far as I can tell |
Aha. This is probably the problem then, as we do not use the message, but only the main name. |
@rullzer would it be possible to have a more meaningful throwable, like "virus detected", this way we could use it better on android. |
We can't really do that. The app has to throw an exception that the server has predefined. Creating specialized exceptions for each app is not really scaleable. Can't you just pass on the message (it should be translated anyways)? |
In case of error, instead of a generic error message, an upload will
display whichever message is returned in the Sabre Exception, if
applicable.
To test this enable the antivirus app and upload a EICAR test virus file or so.
Ref owncloud/core#28620