Skip to content

Commit 14fd994

Browse files
committed
Add support for setting old save path
1 parent 85a4d70 commit 14fd994

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ type Config struct {
2323
Draft bool
2424
// Prerelease permits an upgrade to a "pre-release" version (default to false).
2525
Prerelease bool
26+
// To prevent automatic removal of the old binary, and allow you to test an update prior to manual removal.
27+
OldSavePath string
2628
}

update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func (up *Updater) decompressAndUpdate(src io.Reader, assetName, assetURL, cmdPa
9999

100100
log.Printf("Will update %s to the latest downloaded from %s", cmdPath, assetURL)
101101
return update.Apply(asset, update.Options{
102-
TargetPath: cmdPath,
102+
TargetPath: cmdPath,
103+
OldSavePath: up.oldSavePath,
103104
})
104105
}
105106

updater.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Updater struct {
1919
universalArch string // only filled in when needed
2020
prerelease bool
2121
draft bool
22+
oldSavePath string
2223
}
2324

2425
// keep the default updater instance in cache
@@ -71,6 +72,7 @@ func NewUpdater(config Config) (*Updater, error) {
7172
universalArch: universalArch,
7273
prerelease: config.Prerelease,
7374
draft: config.Draft,
75+
oldSavePath: config.OldSavePath,
7476
}, nil
7577
}
7678

0 commit comments

Comments
 (0)