[WIP] Remove updater index filename setting
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
type Downloader struct {
|
||||
dir string
|
||||
indexFile string
|
||||
indexURLs []string
|
||||
bundle *Bundle
|
||||
version *semver.Version
|
||||
@@ -33,7 +32,6 @@ type Downloader struct {
|
||||
func CreateDownloader(index UpdateIndex) Downloader {
|
||||
return Downloader{
|
||||
dir: index.DownloadDirectory,
|
||||
indexFile: index.IndexFile,
|
||||
indexURLs: index.IndexURLs,
|
||||
}
|
||||
}
|
||||
@@ -78,7 +76,7 @@ func (d *Downloader) downloadIndexFile(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Write the content into a file.
|
||||
indexFilepath := filepath.Join(d.dir, d.indexFile)
|
||||
indexFilepath := filepath.Join(d.dir, indexFilename)
|
||||
err = os.WriteFile(indexFilepath, []byte(content), defaultFileMode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write index file: %w", err)
|
||||
@@ -98,7 +96,7 @@ func (d *Downloader) Verify() error {
|
||||
}
|
||||
|
||||
func (d *Downloader) parseBundle() error {
|
||||
indexFilepath := filepath.Join(d.dir, d.indexFile)
|
||||
indexFilepath := filepath.Join(d.dir, indexFilename)
|
||||
var err error
|
||||
d.bundle, err = LoadBundle(indexFilepath)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,6 +18,8 @@ const (
|
||||
updateFailedNotificationID = "updates:update-failed"
|
||||
corruptInstallationNotificationID = "updates:corrupt-installation"
|
||||
|
||||
indexFilename = "index.json"
|
||||
|
||||
// ResourceUpdateEvent is emitted every time the
|
||||
// updater successfully performed a resource update.
|
||||
ResourceUpdateEvent = "resource update"
|
||||
@@ -39,7 +41,6 @@ type UpdateIndex struct {
|
||||
PurgeDirectory string
|
||||
Ignore []string
|
||||
IndexURLs []string
|
||||
IndexFile string
|
||||
AutoApply bool
|
||||
NeedsRestart bool
|
||||
}
|
||||
@@ -176,7 +177,6 @@ func (u *Updates) UpdateFromURL(url string) error {
|
||||
index := UpdateIndex{
|
||||
DownloadDirectory: u.downloader.dir,
|
||||
IndexURLs: []string{url},
|
||||
IndexFile: u.downloader.indexFile,
|
||||
}
|
||||
|
||||
// Initialize with proper values and download the index file.
|
||||
@@ -214,7 +214,7 @@ func (u *Updates) applyUpdates(downloader Downloader, force bool) error {
|
||||
log.Infof("update: starting update: %s %s -> %s", currentBundle.Name, currentBundle.Version, downloadBundle.Version)
|
||||
}
|
||||
|
||||
err := u.registry.performRecoverableUpgrade(downloader.dir, downloader.indexFile)
|
||||
err := u.registry.performRecoverableUpgrade(downloader.dir, indexFilename)
|
||||
if err != nil {
|
||||
// Notify the user that update failed.
|
||||
notifications.NotifyPrompt(updateFailedNotificationID, "Failed to apply update.", err.Error())
|
||||
|
||||
@@ -36,7 +36,7 @@ func CreateRegistry(index UpdateIndex) (Registry, error) {
|
||||
}
|
||||
// Parse bundle
|
||||
var err error
|
||||
registry.bundle, err = LoadBundle(filepath.Join(index.Directory, index.IndexFile))
|
||||
registry.bundle, err = LoadBundle(filepath.Join(index.Directory, indexFilename))
|
||||
if err != nil {
|
||||
return Registry{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user