Android Question Sending files

In our app we're using a variant of the tracker from here: https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#content

When the location changes there is a generated an file and send to the server. (A)
However there is also a process that sends all present files (not only tracker-info). (B)

These two a sometimes sending the files twice. For example when process A is sending but not yet has deleted the file. Then process B is started in the background and is sending the same file again.

Do you have any thoughts on how to prevent this?
 

teddybear

Well-Known Member
Licensed User
I have a question. why does process B send that file? According to your logic, process A will delete the file after sending it.
If it is considered that process A may fail to send the file, you can specify a special filename when sending.
 
Upvote 0

Xfood

Expert
Licensed User
I would put a global variable Variable A = false, when procedure A is running it puts variable A = true, if procedure B finds variable A = true, it does nothing, and tries again as soon as Variable A goes back to False,
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
In our app we're using a variant of the tracker from here: https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#content

When the location changes there is a generated an file and send to the server. (A)
However there is also a process that sends all present files (not only tracker-info). (B)

These two a sometimes sending the files twice. For example when process A is sending but not yet has deleted the file. Then process B is started in the background and is sending the same file again.

Do you have any thoughts on how to prevent this?
Option 1 - use a database in your app and save each sent file name. Check this database before send each file.
Option 1 - on your server check every incoming file
 
Upvote 0
I have a question. why does process B send that file? According to your logic, process A will delete the file after sending it.
If it is considered that process A may fail to send the file, you can specify a special filename when sending.
Correct. But the file hasn't been deleted when process B is started (from a timer). So process A is sending (and waiting for completion) when process B is started and finds the same file.
 
Upvote 0
Option 1 - use a database in your app and save each sent file name. Check this database before send each file.
Option 1 - on your server check every incoming file
I like option 1 (as well as the true/false from Xfood) and go further with this.
Option 2 I don't like because then I'm still sending files twices which means the server is loaded more
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Correct. But the file hasn't been deleted when process B is started (from a timer). So process A is sending (and waiting for completion) when process B is started and finds the same file.
My solution:
When the location changes, generate an file that is a special filename just for process A and process B ignores it .if you fail to send it then rename it for process B
 
Upvote 0
Top