From d2bff659538e60021d564ae970820b0555c9f548 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 9 Jun 2020 17:53:39 +0200 Subject: [PATCH] Add cleanup config (#23) --- CHANGELOG.md | 4 ++++ assets/assets.go | 7 +++++-- build.properties | 2 +- main.go | 12 ++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f6f8c0..49e7379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2020.05-15 (2020/06/09) + +* Add `cleanup` config (#23) + ## 2020.05-14 (2020/05/29) * Fix addons startup (portapps/phyrox-portable#3) diff --git a/assets/assets.go b/assets/assets.go index eb5a342..12c3240 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -20,7 +20,7 @@ import ( func bindataRead(data []byte, name string) ([]byte, error) { gz, err := gzip.NewReader(bytes.NewBuffer(data)) if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %w", name, err) } var buf bytes.Buffer @@ -28,7 +28,7 @@ func bindataRead(data []byte, name string) ([]byte, error) { clErr := gz.Close() if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %w", name, err) } if clErr != nil { return nil, err @@ -183,6 +183,9 @@ var _bindata = map[string]func() (*asset, error){ "Waterfox.lnk": waterfoxLnk, } +// AssetDebug is true if the assets were built with the debug flag enabled. +const AssetDebug = false + // AssetDir returns the file names below a certain // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the diff --git a/build.properties b/build.properties index de3b3f0..cd61788 100644 --- a/build.properties +++ b/build.properties @@ -6,7 +6,7 @@ app = waterfox app.name = Waterfox app.type = archive app.version = 2020.05 -app.release = 14 +app.release = 15 app.homepage = https://www.waterfox.net/ # Portable app diff --git a/main.go b/main.go index 322af1b..d6be167 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ type config struct { Profile string `yaml:"profile" mapstructure:"profile"` MultipleInstances bool `yaml:"multiple_instances" mapstructure:"multiple_instances"` DisableTelemetry bool `yaml:"disable_telemetry" mapstructure:"disable_telemetry"` + Cleanup bool `yaml:"cleanup" mapstructure:"cleanup"` } var ( @@ -40,6 +41,7 @@ func init() { Profile: "default", MultipleInstances: false, DisableTelemetry: false, + Cleanup: false, } // Init app @@ -88,6 +90,16 @@ func main() { } } + // Cleanup on exit + if cfg.Cleanup { + defer func() { + utl.Cleanup([]string{ + path.Join(os.Getenv("APPDATA"), "Waterfox"), + path.Join(os.Getenv("LOCALAPPDATA"), "Waterfox"), + }) + }() + } + // Multiple instances if cfg.MultipleInstances { log.Info().Msg("Multiple instances enabled")