mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
GODT-1916: Use XDG_DATA_HOME to store persistent data on linux
This change ensures persistent data is stored in XDG_DATA_HOME instead of XDG_CACHE_HOME on linux. It adds the UserData() method on locations.Provider to return a path suitable for storing persistent data. On linux, this returns $XDG_DATA_HOME/protonmail (likely ~/.local/share/protonmail), and on non-linux this returns os.UserConfigDir() because that is assumed to be a more persistent location than os.UserCacheDir(). locations.Locations has been modified to use this new data directory; gluon and logs are now stored here.
This commit is contained in:
@ -63,7 +63,7 @@ func (j *TestCookieJar) Cookies(u *url.URL) []*http.Cookie {
|
||||
}
|
||||
|
||||
type TestLocationsProvider struct {
|
||||
config, cache string
|
||||
config, data, cache string
|
||||
}
|
||||
|
||||
func NewTestLocationsProvider(dir string) *TestLocationsProvider {
|
||||
@ -72,6 +72,11 @@ func NewTestLocationsProvider(dir string) *TestLocationsProvider {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
data, err := os.MkdirTemp(dir, "data")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cache, err := os.MkdirTemp(dir, "cache")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -79,6 +84,7 @@ func NewTestLocationsProvider(dir string) *TestLocationsProvider {
|
||||
|
||||
return &TestLocationsProvider{
|
||||
config: config,
|
||||
data: data,
|
||||
cache: cache,
|
||||
}
|
||||
}
|
||||
@ -87,6 +93,10 @@ func (provider *TestLocationsProvider) UserConfig() string {
|
||||
return provider.config
|
||||
}
|
||||
|
||||
func (provider *TestLocationsProvider) UserData() string {
|
||||
return provider.data
|
||||
}
|
||||
|
||||
func (provider *TestLocationsProvider) UserCache() string {
|
||||
return provider.cache
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user