question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File downloaded file gets truncated in linux if calling quitAndInstall.

See original GitHub issue

I am trying to implement automatic updates, so when the newer file is downloaded I want to quitAndInstall in order to use the new version. However the problem is that when I call quitAndInstall from the update-downloaded listener handler, the file gets truncated to around half the size (the file is around 100Mb, and it ends in between 50Mb and 40Mb, it is not deterministic. Makes me think that when the update-downladed event is triggered, the file has not been completely flushed to disk, so if you quit too quickly you end with a truncated file. If I do not call quitAndInstall then the file is downloaded correctly and if I manually quit and start the new version will work.

Coincidentally this made me wonder, what would happen if the download fails before the new version has been completely downloaded? currently it is overwriting the older version, so if it fails it seems like you end up with a broken app. This is normally resolved by saving to a new name and then doing a rename when ready, however I do not know if it is possible to do an atomic remove (old version) and rename (new version) so that it is guaranteed that you will broke an existing app.

Any insights ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
megahertzcommented, Nov 12, 2021

FIxed in v2.0.11

0reactions
megahertzcommented, Nov 12, 2021

Sorry, sometimes I absolutely have no time for opensource. Anyway, I still have plans to make a release on the week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the cause of file truncation? - UNIX and Linux Forums
Hi, I have a program that gets called from the front end of my application. Actually it creates some temporary files and uses...
Read more >
Truncating a file while it's being used (Linux) - Stack Overflow
As of coreutils 7.0, there is a truncate command.
Read more >
wget truncated my files - linux - Super User
According to wget's man page, it will either continue where it left off if possible, or not do anything and leave the existing...
Read more >
How can I check if a file can be created or truncated ...
Before I get into the guts of the script, I want to make a reasonable check if the file can be created/overwritten, but...
Read more >
Fixing a Truncated MP4 File - YouTube
If your camera ran out of battery or your computer froze in the middle of a recording, you may be left with an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found