Skip to content
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

Downloading builds(updates) more than once even if downloaded already #3003

Closed
developeryashraj opened this issue Jun 11, 2018 · 2 comments
Closed

Comments

@developeryashraj
Copy link
Contributor

developeryashraj commented Jun 11, 2018

  • Version: 20.15.1
  • Target: Windows

I am facing issues with electron-updater. Currently, electron updater downloads a new version of builds every time when it checks for an update even if that new version has been downloaded already. So considering application size is 50 MB then every time when it checks for an update, it uses 50MB of client's data and server bandwidth.

I know that Github issues are not for questions so I have already asked this on StackOverflow as well but did not get any help yet. Detail of this is available here:- https://stackoverflow.com/questions/50744254/electron-auto-updater-downloading-multiple-builds

My other problem is similar to #3000 . So I haven't specified details here but you can get it on the stack.

My package json is

{
  "name": "electorn_application",
  "version": "10.1.1",
  "private": true,
  "main": "main.js",
  "author": "Yashraj",
  "homepage": "http://xyz.com",
  "description": "A Good Software",
  "dependencies": {
    "body-parser": "~1.18.3",
    "dateformat": "^3.0.3",
    "debug": "~3.1.0",
    "electron-is-dev": "^0.3.0",
    "electron-updater": "^2.21.10",
    "express": "~4.16.3",
    "jade": "^1.11.0",
    "jquery": "^3.3.1",
    "lodash": "^4.17.10",
    "mosca": "^2.8.1",
    "mqtt": "^2.18.0",
    "ncp": "^2.0.0",
    "request": "^2.87.0",
    "serve-favicon": "~2.5.0",
    "socket.io": "^2.1.1",
    "sqlite3": "^4.0.0",
    "sqlite3-transactions": "0.0.5",
    "xtend": "^4.0.1"
  },
  "build": {
    "publish": [
      {
        "provider": "generic",
        "url": "http://xyz.com"
      }
    ],
    "win": {
      "icon": "./icons/icon.ico"
    }
  },
  "scripts": {
    "start": "electron .",
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "electron-builder",
    "build:linux": "electron-builder --linux",
    "postinstall": "electron-builder install-app-deps"
  },
  "devDependencies": {
    "electron": "^2.0.2",
    "electron-builder": "^20.15.1"
  }
}
@developeryashraj
Copy link
Contributor Author

developeryashraj commented Jun 11, 2018

@develar, @MariaDima Can you please help me out here? I found that fileinfo comparison is not returning true even if both objects are same. I found it here. Also I found that those lines are different in my node_modules. Does it make sense?? I am having below code in my file.

return (0, _lodash().default)(_this.versionInfo, versionInfo) && (0, _lodash().default)(_this.fileInfo, fileInfo) && (yield (0, _fsExtraP().pathExists)(updateFile));

Scenario:
If an update is already downloaded on the first time when I do "checkForUpdate" then it does not reach to this line because _this.versionInfo and _this.file is null so does not go into the if condition. But once I do "checkForUpdate", values for this object is set and now on the second time when I do "checkForUpdate" it goes into the condition and returns false because of fileInfo comparison. I give it a try by removing this line (0, _lodash().default)(_this.fileInfo, fileInfo) from my code and it works like a charm.

  1. Shouldn't my code be same as isEqual rather then (0, _lodash().default) 🤔? Or it is converted to (0, _lodash().default) during npm install! I think it's a compiled version.
  2. What can be the reason that this fileinfo comparison fails? i logged both the objects and they looks same!

@developeryashraj
Copy link
Contributor Author

While digging down deep I found that somehow URL constructor in this.fileInfo and in fileInfo fails comparison using lodash. So currently I have just compared this.fileInfo.info to make it work properly. I have also submitted PR for the same if this change is proper:- #3007

Below is console log of this.fileInfo

{ url: URL {
     href: 'http://www.xyz.com/installation/electron%20Setup%2010.1.5.exe',
     origin: 'http://www.xyz.com',
     protocol: 'http:',
     username: '',
     password: '',
     host: 'www.xyz.com',
     hostname: 'www.xyz.com',
     port: '',
     pathname: '/installation/electron%20Setup%2010.1.5.exe',
     search: '',
     searchParams: URLSearchParams {},
     hash: '' },
  info:
   { url: 'electron Setup 10.1.5.exe',
     sha512: 'N0FtTCowmdKkJO4b6XSmC+i55ORcgfjlkx85ZsnKTq8xgG/AE6km9YY596sGgCirMIc0XFxfrl16bnQ/+thHFA==',
     size: 51484720 } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants