GODT-1671: Implement Quit & Restart mechanism

This commit is contained in:
Romain LE JEUNE
2022-07-28 16:39:56 +02:00
committed by Jakub
parent f44d1c4b9d
commit 22a8aab151
26 changed files with 1255 additions and 701 deletions

View File

@ -38,14 +38,16 @@ import (
type Locations struct {
userConfig, userCache string
configName string
configGuiName string
}
// New returns a new locations object.
func New(provider Provider, configName string) *Locations {
return &Locations{
userConfig: provider.UserConfig(),
userCache: provider.UserCache(),
configName: configName,
userConfig: provider.UserConfig(),
userCache: provider.UserCache(),
configName: configName,
configGuiName: configName + "-gui",
}
}
@ -54,6 +56,11 @@ func (l *Locations) GetLockFile() string {
return filepath.Join(l.userCache, l.configName+".lock")
}
// GetGuiLockFile returns the path to the lock file (e.g. ~/.cache/<company>/<app>/<app>.lock).
func (l *Locations) GetGuiLockFile() string {
return filepath.Join(l.userCache, l.configGuiName+".lock")
}
// GetLicenseFilePath returns path to liense file.
func (l *Locations) GetLicenseFilePath() string {
path := l.getLicenseFilePath()
@ -210,6 +217,7 @@ func (l *Locations) Clear() error {
l.userCache,
).Except(
l.GetLockFile(),
l.GetGuiLockFile(),
l.getUpdatesPath(),
).Do()
}
@ -226,6 +234,7 @@ func (l *Locations) ClearUpdates() error {
func (l *Locations) Clean() error {
return files.Remove(l.userCache).Except(
l.GetLockFile(),
l.GetGuiLockFile(),
l.getLogsPath(),
l.getCachePath(),
l.getUpdatesPath(),