owncloud / android

:phone: The ownCloud Android App
GNU General Public License v2.0
3.79k stars 3.05k forks source link

[FEATURE REQUEST] Block UI when deleting files #4270

Closed parneet-guraya closed 7 months ago

parneet-guraya commented 8 months ago

Fix: #4231

https://github.com/owncloud/android/assets/111801812/6fb3ed46-de0e-4b1f-a628-0a25dff91137

parneet-guraya commented 8 months ago

@JuancaG05 Have a look :-)

JuancaG05 commented 8 months ago

(For QA purposes) Things changed here:

jesmrec commented 7 months ago

hi @parneet-guraya! thanks again for your valuable contribution. After passing code review, QA stage is ongoing and i detected a behaviour that deserves a look:

It's related with videos preview, that also implements the blocking behaviour as well as pictures preview and list of files.

The point is that videos can be streamed, that means, no local copy in device while the preview is running. If you try to remove a non-downloaded video from the preview (streamed), an error is displayed:

Remove failed because unknown error

Behaviour should be the same as downloaded and streamed videos.

Could you take a look?

parneet-guraya commented 7 months ago

@jesmrec Hi :wave: ,

I believe you're talking about deleting file while the video preview is playing. But, strangely I couldn't reproduce the same behaviour you're talking about.

https://github.com/owncloud/android/assets/111801812/7b442ed0-78b0-42a5-b537-fb64e84a06a7

jesmrec commented 7 months ago

yes, this is the scenario. I was researching a little bit and noticed that it depends on the file locking feature. Checking the following logs i caught trying to reproduce the scenario:

D: 2024-01-09 09:19:43:628(LogInterceptor.kt:67)REQUEST 919b576e-3cae-4c5e-aa31-cc09b04bd34f {"request":{"headers":{"X-Request-ID":"919b576e-3cae-4c5e-aa31-cc09b04bd34f","User-Agent":"Mozilla/5.0 (Android) ownCloud-android/4.2-beta.1","Accept-Language":"en","Accept-Encoding":"identity","Authorization":"Bearer [redacted]","Content-Length":"0","Host":"cloud.xxxx.com","Connection":"Keep-Alive","Cookie":"oc_sessionPassphrase=pQ%2FmwZ9utKf8txT4AUetdKrAg6vVRmEDWE40VdCRRm8%2FsVFQS%2BHEtAZjyAUDWA%2FdS5YL5WTye11q66MSYaWub1ZNjv7VN%2F3IeEcuHNIoljmNlbeHDkB6DSLUrEPjDuib; ocuhsyihz2sp=vm2cv7pphc83rra48jtbjak93n"},"info":{"id":"919b576e-3cae-4c5e-aa31-cc09b04bd34f","method":"DELETE","url":"https://cloud.xxxx.com/remote.php/dav/files/jrecio/RPReplay_Final1702648216.MP4"}}}
D: 2024-01-09 09:19:43:659(LogInterceptor.kt:133)RESPONSE 919b576e-3cae-4c5e-aa31-cc09b04bd34f {"response":{"body":{"data":"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<d:error xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\">\n  <s:exception>OCA\\DAV\\Connector\\Sabre\\Exception\\FileLocked</s:exception>\n  <s:message>\"RPReplay_Final1702648216.MP4\" is locked</s:message>\n</d:error>\n","length":248},"headers":{"Date":"Tue, 09 Jan 2024 08:19:43 GMT","Server":"Apache/2.4.41 (Ubuntu)","Strict-Transport-Security":"max-age=15768000","X-Content-Type-Options":"nosniff","X-XSS-Protection":"0","X-Robots-Tag":"none","X-Frame-Options":"SAMEORIGIN","X-Download-Options":"noopen","X-Permitted-Cross-Domain-Policies":"none","Expires":"Thu, 19 Nov 1981 08:52:00 GMT","Cache-Control":"no-store, no-cache, must-revalidate","Pragma":"no-cache","Set-Cookie":"oc_sessionPassphrase=pQ%2FmwZ9utKf8txT4AUetdKrAg6vVRmEDWE40VdCRRm8%2FsVFQS%2BHEtAZjyAUDWA%2FdS5YL5WTye11q66MSYaWub1ZNjv7VN%2F3IeEcuHNIoljmNlbeHDkB6DSLUrEPjDuib; expires=Tue, 09-Jan-2024 08:39:43 GMT; Max-Age=1200; path=/; secure; HttpOnly; SameSite=Lax","Content-Security-Policy":"default-src 'none';","Content-Length":"248","Keep-Alive":"timeout=5, max=100","Connection":"Keep-Alive","Content-Type":"application/xml; charset=utf-8"},"info":{"id":"919b576e-3cae-4c5e-aa31-cc09b04bd34f","method":"DELETE","reply":{"cached":false,"duration":391,"durationString":"duration(0h, 0min, 0s, 391ms)","status":423,"version":"http/1.1"},"url":"https://cloud.xxxx.com/remote.php/dav/files/jrecio/RPReplay_Final1702648216.MP4"}}}
D: 2024-01-09 09:19:43:661(RemoteOperationResult.java:320)RemoteOperationResult has processed UNHANDLED_HTTP_CODE: 423 Locked
I: 2024-01-09 09:19:43:662(RemoveRemoteFileOperation.kt:66)Remove /RPReplay_Final1702648216.MP4 - HTTP status code: 423
D: 2024-01-09 09:19:43:663(FileOperationsViewModel.kt:307)Use case executed: RemoveFileUseCase with result: Error(throwable=com.owncloud.android.domain.exceptions.UnhandledHttpCodeException)

when the request to remove is sent, file is locked (i can't tell you the reason, maybe because another video session/reproduction). Then, server sends a 423 response that is not handled in our app, throwing a UnhandledHttpCodeException.

423 is defined but i don't find any use of that constant.

so, the way to avoid this is handling the 423 to show a proper error (File is currently locked or something similar), but this is out of the scope of this issue.

For sure, it does not happen every time, so in your try it did not happen and you couldn't reproduce

I will open issue with the 423 stuff and we can move forward this one.