Skip to content

Remove temporary files when updating library_index.json #4361

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

Merged
merged 2 commits into from
Dec 30, 2015

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Dec 29, 2015

This is a tentatve fix for #4272 #4332, following @vicnevicne hint.

I'm not able to reproduce the bug, @vicnevicne @MichaelJonker if you can reproduce it, by any chanche, can you try the fix? (ArduinoBot should make a build in a moment...)

@cmaglie cmaglie added feature request A request to make an enhancement (not a bug fix) Component: IDE user interface The Arduino IDE's user interface labels Dec 29, 2015
@cmaglie cmaglie self-assigned this Dec 29, 2015
@cmaglie cmaglie added this to the Release 1.6.8 milestone Dec 29, 2015
@vicnevicne
Copy link

@cmaglie I'm confirming the fix is OK. Thanks.
In fact, the issue is easy to reproduce : use the library manager in 1.6.7 (or a version without your fix) and a file "C:\Users\AppData\Local\Arduino15\library_index.json.tmp.gz" gets created but not deleted. Then exit, let one minute pass, restart the same procedure and you'll notice the timestamp of that .gz file does not change (the file is not replaced). So the same file gets unzipped over and over.
With your fixed version, the .gz file is correctly deleted.
Here is the video with 2 successive launches of 1.6.7 and then 2 with your 1.6.8 : http://screencast.com/t/a8hGl2sd1S
So it's all good for me.
@matthijskooijman Could be done indeed, but I guess the separate download/rename/unzip process eases debugging (well, maybe debugging is the reason why the delete was forgotten in the first place).
For me anything goes as long as it works ;-)

@cmaglie
Copy link
Member Author

cmaglie commented Dec 30, 2015

@vicnevicne
thanks for testing and for the screencast!
It seems that the File.renameTo(..) is not able to replace the destination file on Windows (while it does on linux/unix, that's why I wasn't able to reproduce here).

@matthijskooijman
right, I've added another commit and removed the extra rename. I'll check the result with @vicnevicne's procedure and merge straight away if everything is ok.

@matthijskooijman
Copy link
Collaborator

@cmaglie The extra commit looks good, that's exactly what I meant indeed.

@cmaglie cmaglie merged commit cce61f6 into arduino:master Dec 30, 2015
@cmaglie cmaglie deleted the update-tmp-file-fix branch December 30, 2015 10:22
@vicnevicne
Copy link

@cmaglie : I didn't know renameTo() does overwrite on Unix/Linux, but I know for sure it doesn't on Windows indeed.
The doc confirms that "Many aspects of the behavior of this method are inherently platform-dependent: [...] it might not succeed if a file with the destination abstract pathname already exists" - http://docs.oracle.com/javase/8/docs/api/java/io/File.html#renameTo-java.io.File-

And the improvement following @matthijskooijman 's suggestion is even better. I checked that the downloader also requires the target file to be deleted beforehand, and it's the case (otherwise it appends to it, which gets detected as a corrupt download and forces the fallback to download the non-gz version).

So +1 for the last version, avoiding renameTo() altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE user interface The Arduino IDE's user interface feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants