Skip to content

Commit

Permalink
Add support for setting old save path
Browse files Browse the repository at this point in the history
  • Loading branch information
GRMrGecko committed Oct 12, 2024
1 parent 85a4d70 commit 14fd994
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ type Config struct {
Draft bool
// Prerelease permits an upgrade to a "pre-release" version (default to false).
Prerelease bool
// To prevent automatic removal of the old binary, and allow you to test an update prior to manual removal.
OldSavePath string
}
3 changes: 2 additions & 1 deletion update.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func (up *Updater) decompressAndUpdate(src io.Reader, assetName, assetURL, cmdPa

log.Printf("Will update %s to the latest downloaded from %s", cmdPath, assetURL)
return update.Apply(asset, update.Options{
TargetPath: cmdPath,
TargetPath: cmdPath,
OldSavePath: up.oldSavePath,
})
}

Expand Down
2 changes: 2 additions & 0 deletions updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Updater struct {
universalArch string // only filled in when needed
prerelease bool
draft bool
oldSavePath string
}

// keep the default updater instance in cache
Expand Down Expand Up @@ -71,6 +72,7 @@ func NewUpdater(config Config) (*Updater, error) {
universalArch: universalArch,
prerelease: config.Prerelease,
draft: config.Draft,
oldSavePath: config.OldSavePath,
}, nil
}

Expand Down

0 comments on commit 14fd994

Please sign in to comment.