Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions s3update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type Updater struct {
S3ReleaseKey string
// S3VersionKey represents the key on S3 to download the current version
S3VersionKey string
// PostUpdateHandler represents the function to be passed that is to be run after pulling the app
PostUpdateHandler func(dest string) error
}

// validate ensures every required fields is correctly set. Otherwise and error is returned.
Expand Down Expand Up @@ -147,6 +149,16 @@ func runAutoUpdate(u Updater) error {
return err
}

// Run the PostUpdateHandler handler
if u.PostUpdateHandler != nil {
fmt.Printf("s3update: updating using post handler\n")
if err := u.PostUpdateHandler(dest); err != nil {
fmt.Printf("s3update: error updating using post handler :: %s\n", err)
os.Rename(destBackup, dest)
return err
}
}

// Removing backup
os.Remove(destBackup)

Expand Down