Comments (12)
FIxed in v2.0.11
from electron-simple-updater.
I as I see at least in linux it is possible to rename a temporary file to an existing file to effectively achieve an atomic replacement of the old version by the new version: https://unix.stackexchange.com/questions/24395/rewrite-existing-file-so-that-it-gets-replaced-by-new-version-atomically-only-o
from electron-simple-updater.
Ok, I could figure out that currently the new version is being downloaded to the /tmp dir and then at the next quit it renames the new version to the old one and we are in business.
Regarding the issue with truncation, a workaround that seems to work is this:
updater.on("update-downloaded", (meta: {}) => {
logger.debug("update downloaded", meta);
setTimeout(() => {
updater.quitAndInstall();
}, 5000);
});
But it seems a bit shaky, and it should not be needed in the first place I think.
from electron-simple-updater.
Update. Seems like the workaround above does not work always, as if 5 seconds it is not enough for the whole file to be downloaded, it almost seems as if the event update-downladed
is actually triggered before the whole file is downloaded :/
from electron-simple-updater.
Thanks for the information, I'll review again the downloader code on this week.
from electron-simple-updater.
Actually I think the issue comes from the httpreq package:
https://github.com/SamDecrock/node-httpreq/blob/c2dbc959ea8538ffcbb12c5a7e7e1b90abd7d5e0/lib/httpreq.js#L330
It is listening to res.on('end')
to decide the file has been downloaded and stored to disk, however it should be listening to the "target" stream instead, downloadStream.on('end'). Examining a bit more the quality of the httpreq code and the pretty low stars rate I would seriously consider to replace this library by something more battle tested and popular such as "request" or "node-fetch".
from electron-simple-updater.
In fact it should not even be listening to the "end" event but to the "finish" event. So a working code for download a file would be more in this style:
async function download() {
const res = await fetch(srcFileUrl)
await new Promise((resolve, reject) => {
const fileStream = fs.createWriteStream(destinationPath);
res.body.pipe(fileStream);
res.body.on("error", (err) => {
reject(err);
});
fileStream.on("finish", function() {
resolve();
});
});
}
from electron-simple-updater.
from electron-simple-updater.
Actually I think the issue I reporting here is the same as this one: #58
The reason why the poster of #58 got it working is because he implemented downloadFile correctly.
from electron-simple-updater.
Thank you very much for details. Yes, I'm thinking about migrating to axios. Unfortunately, I have no time at this moment to dive into the issue, will try to do that in the beginning of the next week, maybe earlier.
from electron-simple-updater.
Since this issue was a show stopper for me I ended up using the standard electron-updater which actually works really well. Just in case somebody else encounters this issue thats the workaround I found.
from electron-simple-updater.
Sorry, sometimes I absolutely have no time for opensource. Anyway, I still have plans to make a release on the week.
from electron-simple-updater.
Related Issues (20)
- NSIS Support HOT 3
- checkForUpdates not responding HOT 7
- Could not create temporary directory HOT 2
- Squirrel.Windows DEPRECATED :( HOT 6
- Enable downgrading/rollback HOT 1
- Events 'update-not-available', 'update-available', etc. not firing Render HOT 6
- Update often fails on Raspberry Pi HOT 4
- Update is disabled because the app is not packaged HOT 4
- opt.logger.debug is not a function HOT 1
- What should be path of update for windows HOT 2
- Add User agent to request HOT 5
- Simple Updater: The Request was Aborted HOT 6
- Empty warning text HOT 2
- Support for download progress (important for slow connections) HOT 3
- Linux App image HOT 1
- cannot perform update "Update is disabled because the app is not packaged" HOT 3
- Where can i locate the downlaoded electron packages? HOT 2
- Stuck at downloading windows squirrel HOT 3
- Documentation for updates.json ? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-simple-updater.