Locus Action - replace existing file

Bob Denny shared this idea 6 years ago
Completed

I need a way to use a Locus Action to update an existing file (map, etc). Maybe a new <after> keyword or ??

Comments (5)

photo
1

Hello Bob,


Locus should automatically overwrite all downloaded files. This do not happen to you?

photo
1

The files I tried to replace resulted in a toast "already in use". As usual, I will now do a more specific test and get back with the results. I am not in the office until maybe Saturday. Don't hold the .3 :-)

photo
1

Ah ha! If the file is the same size it says "already exists" but if the file has the same name, but is a different size, it updates it. Further tests indicate that the size="nn" in the XML file is compared to the actual size of the (existing) file on the device, and if the same, the download is SKIPPED and you get "already exists". This should probably be documented.


Now it gets interesting... if the size="" in the XML is different from the actual size of the file on the device, the file is always downloaded and replaces what is there. Next time, the size will still be different, and the file will again be downloaded.


I thought that the file size in the XML is used as a "check" to see if the download perhaps was incomplete or ??? But the file will always be downloaded and used if the size in the XML does not match the actual size of the file (whether it already exists on the device or not). It seems that the (only) use of size="" is to skip a download if a file with the same name and the same size already exists on the device. Personally, I like this behavior, it allows me to distribute things and then provide updates later via the same web page link! It does provide the "replace" capability but in a "smart" way that avoids downloading what is probably the same file that's already on the device! My only complaint is that there doesn't seem to be a check of the actually downloaded file's size against the XML after the file is downloaded so a corrupt file download would be detected. Instead the file is just downloaded and used, and then next time the size doesn't match again, and the file is again downloaded, etc. etc.


I played around with the date="..." option in the XML thinking that it might also be used to detect duplicates, but I am unsure what time zone the date/time is supposed to be for. What if the device is on Czech time and the server is in Africa? The date/time should probably be in UTC (so called GMT).

photo
1

It's exactly as you wrote, "size" is used only for a check.


If download fails from any reason, further actions won't be performed at all!


To make it "better", I should add another parameter "checksum" to control if download is OK or not. This "size" value was just a very quick and not a perfect solution.


And date - rather forget on it. Later I discovered that I'm unable to correctly set "date" on a new downloaded file, so this parameter is useless except rare cases.

photo
1

OK, thanks for the confirmation. I am happy with it!