diff --git a/s3update.go b/s3update.go index fa71b3c..d6309e0 100644 --- a/s3update.go +++ b/s3update.go @@ -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. @@ -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)