-
Notifications
You must be signed in to change notification settings - Fork 92
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
fix bug preventing uploading the same large file twice #33
Conversation
SharedPreferences.Editor editor = sharedPref.edit(); | ||
editor.remove(chunkId).apply(); | ||
} else { | ||
SharedPreferences.Editor editor = sharedPref.edit(); |
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.
Duplicate code, can be done before the if block
How are already saved uploads then handled? As in: Will this fix correct them too, does the user need to upload them again after the error and it works then or are they corrupted forever? |
@@ -161,8 +161,13 @@ protected int uploadFile(OwnCloudClient client) throws IOException { | |||
} | |||
|
|||
} finally { | |||
SharedPreferences.Editor editor = sharedPref.edit(); | |||
editor.putStringSet(chunkId, successfulChunks).apply(); | |||
if (this.isSuccess(status)) { |
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.
wouldn't this part make line 158ff obsolete since the finally block takes care of it anyways?
a086381
to
e92f4b3
Compare
@@ -162,7 +162,11 @@ protected int uploadFile(OwnCloudClient client) throws IOException { | |||
|
|||
} finally { | |||
SharedPreferences.Editor editor = sharedPref.edit(); | |||
editor.putStringSet(chunkId, successfulChunks).apply(); | |||
if (this.isSuccess(status)) { |
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.
the success part seems to be exactly the same as the last lines of the try {} part and the finally block will always be executed.
No. |
I hope I did not messed it up, I hast had 3 hours of sleep ;-) This should also fix all older versions and allow to reupload the files as the day string is not included and therefore the chunks will be uploaded again. All was tested on my emulator. |
What happens for Uploads which start at 23:58 and error on 00:05? You then will have chunks from "yesterday" and chunks from "today" of the same file and the same upload. |
Yes, in that case the resume on 00:06 or later will trigger a complete new upload. |
As long as we: a) Don't end up with duplicate, hanging chunks I'm fine And avoid complicating things further. |
I agree with you guys! 👍 So merge? |
@AndyScherzinger this repo still has LGTM? |
Nope, but all PRs that got opened before we removed it still show it. No worries :) |
The successful chunks were stored always, whereas they should only get stored if the upload is not successful.
Ref: nextcloud/android#581