首页 > 解决方案 > 通过亚马逊 s3 的电子自动更新不起作用

问题描述

我正在尝试使用 amazon s3 存储桶设置电子自动更新程序。我没有收到任何错误,但是当我发布新版本时,自动更新程序不会在应用程序屏幕上显示任何更新。但是已发布的最新版本显示在 amazon s3 存储桶中。下面显示了它是如何添加的:

require('dotenv').config({path: __dirname + '/.env'});
const aws4 = require('aws4');
const pkg = require('./package.json');
const {app, BrowserWindow, Menu, protocol, ipcMain} = require('electron');
const log = require('electron-log');
const {autoUpdater} = require("electron-updater");

autoUpdater.on('checking-for-update', () => {
  alert('checking')
  console.log('checking for updates')
  const opts = {
    service: 's3',
      region: pkg.build.publish.region,
      method: 'GET',
      host: `s3-${pkg.build.publish.region}.amazonaws.com`,
      path: path.join('/', pkg.build.publish.bucket, latest_yml_path)
  };
  
  aws4.sign(opts, {
    accessKeyId: 'access key',
    secretAccessKey: 'secret access key'
  });
  // signer.sign(opts); --remove this line --
  autoUpdater.requestHeaders = opts.headers
  document.getElementById('messages').innerText = "checking for updates"
  sendStatusToWindow('Checking for update...');
})

autoUpdater.on('update-available', (info) => {
  alert('update available')
  sendStatusToWindow('Update available.');
})
autoUpdater.on('update-not-available', (info) => {
  sendStatusToWindow('Update not available.');
})
autoUpdater.on('error', (err) => {
  sendStatusToWindow('Error in auto-updater. ' + err);
})
autoUpdater.on('download-progress', (progressObj) => {
  let log_message = "Download speed: " + progressObj.bytesPerSecond;
  log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
  log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
  sendStatusToWindow(log_message);
})
autoUpdater.on('update-downloaded', (info) => {
  sendStatusToWindow('Update downloaded');
});

app.on('ready', function() {
  // Create the Menu
  const menu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(menu);
  console.log('ready')
  
  createDefaultWindow();
  autoUpdater.checkForUpdatesAndNotify();
});

没有错误显示,但也没有消息显示。哪里可能出错了?

标签: amazon-s3electronauto-updateelectron-builder

解决方案


推荐阅读