@ -49,12 +49,6 @@ var (
var (
var (
log = logrus . WithField ( "pkg" , "bridgeUtils/updates" ) //nolint[gochecknoglobals]
log = logrus . WithField ( "pkg" , "bridgeUtils/updates" ) //nolint[gochecknoglobals]
installFileSuffix = map [ string ] string { //nolint[gochecknoglobals]
"darwin" : ".dmg" ,
"windows" : ".exe" ,
"linux" : ".sh" ,
}
ErrDownloadFailed = errors . New ( "error happened during download" ) //nolint[gochecknoglobals]
ErrDownloadFailed = errors . New ( "error happened during download" ) //nolint[gochecknoglobals]
ErrUpdateVerifyFailed = errors . New ( "cannot verify signature" ) //nolint[gochecknoglobals]
ErrUpdateVerifyFailed = errors . New ( "cannot verify signature" ) //nolint[gochecknoglobals]
)
)
@ -67,7 +61,8 @@ type Updates struct {
releaseFixedBugs string
releaseFixedBugs string
updateTempDir string
updateTempDir string
landingPagePath string // Based on Host/; default landing page for download.
landingPagePath string // Based on Host/; default landing page for download.
installerFileBaseName string // File for initial install or manual reinstall. per goos [exe, dmg, sh].
winInstallerFile string // File for initial install or manual reinstall for windows
macInstallerFile string // File for initial install or manual reinstall for mac
versionFileBaseName string // Text file containing information about current file. per goos [_linux,_darwin,_windows].json (have .sig file).
versionFileBaseName string // Text file containing information about current file. per goos [_linux,_darwin,_windows].json (have .sig file).
updateFileBaseName string // File for automatic update. per goos [_linux,_darwin,_windows].tgz (have .sig file).
updateFileBaseName string // File for automatic update. per goos [_linux,_darwin,_windows].tgz (have .sig file).
linuxFileBaseName string // Prefix of linux package names.
linuxFileBaseName string // Prefix of linux package names.
@ -85,7 +80,8 @@ func NewBridge(updateTempDir string) *Updates {
releaseFixedBugs : bridge . ReleaseFixedBugs ,
releaseFixedBugs : bridge . ReleaseFixedBugs ,
updateTempDir : updateTempDir ,
updateTempDir : updateTempDir ,
landingPagePath : "bridge/download" ,
landingPagePath : "bridge/download" ,
installerFileBaseName : "Bridge-Installer" ,
macInstallerFile : "Bridge-Installer.dmg" ,
winInstallerFile : "Bridge-Installer.exe" ,
versionFileBaseName : "current_version" ,
versionFileBaseName : "current_version" ,
updateFileBaseName : "bridge_upgrade" ,
updateFileBaseName : "bridge_upgrade" ,
linuxFileBaseName : "protonmail-bridge" ,
linuxFileBaseName : "protonmail-bridge" ,
@ -103,11 +99,12 @@ func NewImportExport(updateTempDir string) *Updates {
releaseFixedBugs : importexport . ReleaseFixedBugs ,
releaseFixedBugs : importexport . ReleaseFixedBugs ,
updateTempDir : updateTempDir ,
updateTempDir : updateTempDir ,
landingPagePath : "import-export" ,
landingPagePath : "import-export" ,
installerFileBaseName : "Import-Export-Installer" ,
winInstallerFile : "ie/Import-Export-app-installer.exe" ,
macInstallerFile : "ie/Import-Export-app.dmg" ,
versionFileBaseName : "current_version_ie" ,
versionFileBaseName : "current_version_ie" ,
updateFileBaseName : "ie_upgrade" ,
updateFileBaseName : "ie/ ie_upgrade" ,
linuxFileBaseName : "protonmail-import-export" ,
linuxFileBaseName : "ie/ protonmail-import-export-app " ,
macAppBundleName : "ProtonMail Import-Export.app" ,
macAppBundleName : "Import-Export app .app" ,
}
}
}
}
@ -187,11 +184,15 @@ func (u *Updates) getLocalVersion(goos string) VersionInfo {
if goos == "linux" {
if goos == "linux" {
pkgName := u . linuxFileBaseName
pkgName := u . linuxFileBaseName
pkgRel := "1"
pkgRel := "1"
pkgBase := strings . Join ( [ ] string { Host , DownloadPath , pkgName } , "/" )
pkgBaseFile := strings . Join ( [ ] string { Host , DownloadPath , pkgName } , "/" )
pkgBasePath := DownloadPath + "/" + pkgName // add at least one dir
pkgBasePath = filepath . Dir ( pkgBasePath ) // keep only last dir
pkgBasePath = Host + "/" + pkgBasePath // add host in the end to not strip off double slash in URL
versionInfo . DebFile = pkgBase + "_" + u . version + "-" + pkgRel + "_amd64.deb"
versionInfo . DebFile = pkgBaseFile + "_" + u . version + "-" + pkgRel + "_amd64.deb"
versionInfo . RpmFile = pkgBase + "-" + u . version + "-" + pkgRel + ".x86_64.rpm"
versionInfo . RpmFile = pkgBaseFile + "-" + u . version + "-" + pkgRel + ".x86_64.rpm"
versionInfo . PkgFile = strings . Join ( [ ] string { Host , DownloadPath , "PKGBUILD" } , "/" )
versionInfo . PkgFile = strings . Join ( [ ] string { pkgBase Path, "PKGBUILD" } , "/" )
}
}
return versionInfo
return versionInfo
@ -240,7 +241,14 @@ func (u *Updates) versionFileURL(goos string) string {
}
}
func ( u * Updates ) installerFileURL ( goos string ) string {
func ( u * Updates ) installerFileURL ( goos string ) string {
return strings . Join ( [ ] string { Host , DownloadPath , u . installerFileBaseName + installFileSuffix [ goos ] } , "/" )
installerFile := "none"
switch goos {
case "darwin" :
installerFile = u . macInstallerFile
case "windows" :
installerFile = u . winInstallerFile
}
return strings . Join ( [ ] string { Host , DownloadPath , installerFile } , "/" )
}
}
func ( u * Updates ) updateFileURL ( goos string ) string {
func ( u * Updates ) updateFileURL ( goos string ) string {
@ -299,7 +307,8 @@ func (u *Updates) StartUpgrade(currentStatus chan<- Progress) { // nolint[funlen
status . UpdateDescription ( InfoUpgrading )
status . UpdateDescription ( InfoUpgrading )
switch runtime . GOOS {
switch runtime . GOOS {
case "windows" : //nolint[goconst]
case "windows" : //nolint[goconst]
cmd := exec . Command ( "./" + u . installerFileBaseName ) // nolint[gosec]
installerFile := strings . Split ( u . winInstallerFile , "/" ) [ 1 ]
cmd := exec . Command ( "./" + installerFile ) // nolint[gosec]
cmd . Dir = u . updateTempDir
cmd . Dir = u . updateTempDir
status . Err = cmd . Start ( )
status . Err = cmd . Start ( )
case "darwin" :
case "darwin" :