Android Question DropBox: Files Appear to Download From DropBox, But Their Content Show Old Data

Mahares

Expert
Licensed User
Longtime User
I download 6 small text files from DropBox to a folder in FileDirRooExternal so they can be imported into a few SQLite tables on the device and overwrite existing files. File Manager on the device show the download date and time to be newer than the old files date and time. When I check the content of the files in the device, even though they show the latest download date, they do not show new data like the ones located in DropBox. They still show old data. Are the files being downloaded from cache instead of DropBox? If so, how can I delete this cache every time so I can import the new files that are sitting in DropBox?
Any help is very appreciated
 

DonManfred

Expert
Licensed User
Longtime User
You can put some logging... in JobDone where you copy the files to somewhere you could log(Job.getstring) to log the contents of downloaded file before you copy it.
Without any copy we just can guess what happens...
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Where do you place the manager.Sync command? I have the manager.LinkAccount in the Acitvity_create
Like this?
B4X:
manager.LinkAccount  
 manager.sync
Also, how do you know when the SyncCompleted is raised?
Thank you
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I figured that Sub Manager_SyncCompleted (Success As Boolean) a few hours ago. But the problem is that it says: the Sync is successful, but actually it is not true. Here is what I did:
I checked the Dropbox server. The file size is 1.9 MB. Downloaded the file via my DropBox Sync app. I clicked a button like this:
B4X:
Sub btnSync_Click
    manager.Sync  
End Sub
It shows that the Sync is successful. Then I click on another button to download the file, waited several seconds. But the file on the device still shows 1.9 MB instead of the new one sitting on DropBox server which is 920 KB. I waited 5 minutes, reran the program a second time. That is when the file updated to the new size. It took 2 tries, sometimes it takes several tries.
CONCLUSION: Manger.Sync is not reliable, at least in my case. Any ideas from those who use DropBox Sync Lib on a regular and intense basis?
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Erel: The Sync happens almost immediately. I even waited several seconds and minutes after the sync. Here is the code.

B4X:
Sub btnSync_Click
    manager.Sync  
End Sub
Sub Manager_SyncCompleted (Success As Boolean)
    If Success Then
'        Log("Sync successful.")
        ToastMessageShow("Sync successful.",False)
    Else
'       Log("Sync failed.!")
        ToastMessageShow("Sync failed.",False)
'    Else
'        ToastMessageShow("Sync failed.!",False)
    End If
End Sub
I spent all Friday and Saturday testing. Sometimes it takes 3 tries ofrestarting the program to get the most current data, sometimes it takes even 7 tries. But every time, the date and time of the files downloaded is the new date. So I know it is downloading files. The problem is that they are not the new files I just loaded onto the server. They are the files in cache, which are the old files. I have documented the time sequence of all the tests I did if you want them. I was reading in the DropBox developer documentation that the cache is cleared every 3 days. I would like to be able to clear it every time, so the server files download. I hope you can really help me.
 
Upvote 0

junglejet

Active Member
Licensed User
Longtime User
I experience the same behaviour with the native Dropbox client on Android and OS10.
New date, but old file.
It appears to me that files are only downloaded when they are needed.
The file date/time update is not enough to judge that the file is on disk.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The files on the server must always download regardless what is in cache, at least in my case. Does anyone have a solution or workaround for this very serious flaw in DropBox or perhaps a way to disable cache or delete cache prior to download.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Erel:
1.Where do I put the manager.AutoSync =True ? in the Activity_create or in the click button event?.
2. Do I remove this: manager.Sync from the code?
3. If files are in the process of downloading and the user clicks the back key to exit the app, will the files continue to download without corruption? I will try the new memeber and report back. Thank you

B4X:
Sub btnSync_Click
'    manager.Sync   '2/14/14
    manager.AutoSync =True  'new 2/17/14  per new lib 1.25
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Erel says: Try the new version. It adds an AutoSync field. Set it to True. The latest files should be served.
It works a lot better now by adding the new member. And I am getting the new files to the device. The only problem I am still experiencing is this:
From Manager.List I create a list of files that only have a certain extension, then I display each file along with its size in KB via a toastmessage while the files are being downloaded from DropBox server to device. The problem is that the names of the files are correct but the size is always displaying the old cache file size. But the files downloaded to the device show the correct new file sizes which is correct when I check them via File Manager. It may look confusing because it shows a file size, but downloads a different size. I have tried to reinitialize the list a few times, but it did not help.
Thanks a lot
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
When calling Manager.Sync, the SyncCompleted event occurs instantly. The behavior does not change. The new files are downloaded, but the list of files displayed in the toastmessage is still the cache files.
1. What does Manager.Autosync=true actually do? Does it replace the cache with the new fresh files or is the cache bypassed and the new files download directly from the DropBox server?
2. Is there perhaps a way to create a service to simply do the AutoSync, wait several seconds to give it a chance to update, then have another service to do the download. i am not sure how to call a service from another in this particular case where credentials must be authenticated.
 
Upvote 0
Top