You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sync only once wifi continues after connection switch to mobile #1166
As @AndyScherzinger reported (#41 (comment)):
One issue I had with the wifi upload on my vacation was that the sync started being on wifi (as it should) but went on after I lost the wifi connection and further uploaded the files and thus impacted my data plan (being in a foreign country) pretty heavily with no possibility to cancel the uploads (I know their is already an issue opened for cancellations)
@AndyScherzinger:
Imho a "simple" solution would be to check before every file if "wifi only" is activated and wifi connected and then upload the next file and else to stop (or pause).
--> checks the connection (type) but then simply starts uploading, then comes the loop:
Cursor c = db.getAwaitingFiles();
if (c.moveToFirst()) {
do {
So the code checks the connection and if it is appropriate starts uploading without ever checking the precondition (connectivity + user settings) again. So I guess we would have to kind of duplicate the check and also do this check an the beginning of each loop iteration.
One thing I am not sure of is the reference to context. Would it be possible that context somehow gets terminated by Android's life cycle system and at some point in time when using it for checking for the wifi connection the code would crash? (I am not that firm with Android and weak/strong references and the context's life cycle when being used in a receiver instance)
point: you are right. Within the loop there must be an additional check. This is easy and I did it locally.
But the problem is to cancel the current upload. This can be do via FileUploader.cancel(account).
Unfortunenately I could not managed it to get a reference to FileUploader in the BroadcastReceiver.
Therefore I gave up :/
Regarding context: I hope not. I think they stay intact as long as the app lives...
Not sure how to solve the second issue adhoc but wouldn't the first part (stop at least after the currently uploaded file) be an improvement compared to today.
So the other part "cancel an upload of a file during wifi connection lost" could be solved at another point in time on another opened issue. Standard case would be photos and/or videos I guess and at least for the photo use case (which probably is the main one) this would already help quite a lot.
The upload starts again.
But if it tries to resume the failed file or continues with the next one, I cannot say.
But I would bet, that it does not retry :/
changed the title [-]Sync only one wifi continues after connection switch to mobile[/-][+]Sync only once wifi continues after connection switch to mobile[/+]on Mar 30, 2016
Activity
tobiasKaminsky commentedon Sep 20, 2015
@AndyScherzinger:
Imho a "simple" solution would be to check before every file if "wifi only" is activated and wifi connected and then upload the next file and else to stop (or pause).
tobiasKaminsky commentedon Sep 20, 2015
Additionally the upload must receive a broadcast intent if the connection switches from wifi to mobile data and cancel the current and future upload.
AndyScherzinger commentedon Sep 20, 2015
Jepp, agreeing on the solution! :)
AndyScherzinger commentedon Oct 7, 2015
any knowledge on where this would need to be implemented in actual code base?
tobiasKaminsky commentedon Oct 7, 2015
In InstantUploadBroadcastReceiver, function handleConnectivityAction
AndyScherzinger commentedon Oct 7, 2015
Hmm
--> checks the connection (type) but then simply starts uploading, then comes the loop:
Cursor c = db.getAwaitingFiles();
if (c.moveToFirst()) {
do {
So the code checks the connection and if it is appropriate starts uploading without ever checking the precondition (connectivity + user settings) again. So I guess we would have to kind of duplicate the check and also do this check an the beginning of each loop iteration.
AndyScherzinger commentedon Oct 7, 2015
One thing I am not sure of is the reference to context. Would it be possible that context somehow gets terminated by Android's life cycle system and at some point in time when using it for checking for the wifi connection the code would crash? (I am not that firm with Android and weak/strong references and the context's life cycle when being used in a receiver instance)
tobiasKaminsky commentedon Oct 7, 2015
But the problem is to cancel the current upload. This can be do via FileUploader.cancel(account).
Unfortunenately I could not managed it to get a reference to FileUploader in the BroadcastReceiver.
Therefore I gave up :/
Regarding context: I hope not. I think they stay intact as long as the app lives...
AndyScherzinger commentedon Oct 7, 2015
Not sure how to solve the second issue adhoc but wouldn't the first part (stop at least after the currently uploaded file) be an improvement compared to today.
So the other part "cancel an upload of a file during wifi connection lost" could be solved at another point in time on another opened issue. Standard case would be photos and/or videos I guess and at least for the photo use case (which probably is the main one) this would already help quite a lot.
AndyScherzinger commentedon Oct 7, 2015
@tobiasKaminsky Would this be of any help?
--> http://stackoverflow.com/questions/10482171/how-to-get-reference-to-running-service
Lookup for a running service :)
tobiasKaminsky commentedon Oct 7, 2015
@AndyScherzinger Yes, but it would better to solve both, I thin.
I am on IRC, if you want to discuss it.
tobiasKaminsky commentedon Oct 7, 2015
@AndyScherzinger PR is in #1191.
Maybe you can test it?
AndyScherzinger commentedon Oct 7, 2015
Nice! Did you find a solution? :)
AndyScherzinger commentedon Oct 7, 2015
I'll see if I can test drive it tomorrow during the day or in the evening!
AndyScherzinger commentedon Oct 7, 2015
Assuming we have a reconnect to another wifi, would the upload restart?
tobiasKaminsky commentedon Oct 7, 2015
The upload starts again.
But if it tries to resume the failed file or continues with the next one, I cannot say.
But I would bet, that it does not retry :/
masensio commentedon Feb 19, 2016
Now #1191 is merged on master.
I think that PR fixes this issue, so I'll close it.
Thanks @tobiasKaminsky and @AndyScherzinger
[-]Sync only one wifi continues after connection switch to mobile[/-][+]Sync only once wifi continues after connection switch to mobile[/+]