mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
GODT-976 Exclude updates from clearing cache and clear cache, including updates, while switching early access off
This commit is contained in:
@ -165,12 +165,20 @@ func (l *Locations) getUpdatesPath() string {
|
||||
return filepath.Join(l.userCache, "updates")
|
||||
}
|
||||
|
||||
// Clear removes everything except the lock file.
|
||||
// Clear removes everything except the lock and update files.
|
||||
func (l *Locations) Clear() error {
|
||||
return files.Remove(
|
||||
l.getSettingsPath(),
|
||||
l.getLogsPath(),
|
||||
l.getCachePath(),
|
||||
).Except(
|
||||
l.getUpdatesPath(),
|
||||
).Do()
|
||||
}
|
||||
|
||||
// ClearUpdates removes update files.
|
||||
func (l *Locations) ClearUpdates() error {
|
||||
return files.Remove(
|
||||
l.getUpdatesPath(),
|
||||
).Do()
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ func (dirs *fakeAppDirs) UserCache() string {
|
||||
return dirs.cacheDir
|
||||
}
|
||||
|
||||
func TestClearRemovesEverythingExceptLockFile(t *testing.T) {
|
||||
func TestClearRemovesEverythingExceptLockAndUpdateFiles(t *testing.T) {
|
||||
l := newTestLocations(t)
|
||||
|
||||
assert.NoError(t, l.Clear())
|
||||
@ -48,6 +48,18 @@ func TestClearRemovesEverythingExceptLockFile(t *testing.T) {
|
||||
assert.NoDirExists(t, l.getSettingsPath())
|
||||
assert.NoDirExists(t, l.getLogsPath())
|
||||
assert.NoDirExists(t, l.getCachePath())
|
||||
assert.DirExists(t, l.getUpdatesPath())
|
||||
}
|
||||
|
||||
func TestClearUpdateFiles(t *testing.T) {
|
||||
l := newTestLocations(t)
|
||||
|
||||
assert.NoError(t, l.ClearUpdates())
|
||||
|
||||
assert.FileExists(t, l.GetLockFile())
|
||||
assert.DirExists(t, l.getSettingsPath())
|
||||
assert.DirExists(t, l.getLogsPath())
|
||||
assert.DirExists(t, l.getCachePath())
|
||||
assert.NoDirExists(t, l.getUpdatesPath())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user