Skip to content

Commit

Permalink
Merge pull request #7955 from jandubois/session-data
Browse files Browse the repository at this point in the history
Factory-reset should also delete the Electron session data directory
  • Loading branch information
mook-as authored Dec 20, 2024
2 parents f05d746 + d5daac5 commit 5aea59b
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import * as window from '@pkg/window';
import { closeDashboard, openDashboard } from '@pkg/window/dashboard';
import { openPreferences, preferencesSetDirtyFlag } from '@pkg/window/preferences';

Electron.app.setPath('userData', path.join(paths.appHome, 'electron'));
Electron.app.setPath('cache', paths.cache);
Electron.app.setAppLogsPath(paths.logs);

Expand Down
1 change: 1 addition & 0 deletions src/go/rdctl/pkg/factoryreset/delete_data_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func DeleteData(ctx context.Context, appPaths paths.Paths, removeKubernetesCache
appPaths.Config,
appPaths.Logs,
appPaths.ExtensionRoot,
appPaths.OldUserData,
}
pathList = append(pathList, appHomeDirectories(appPaths)...)

Expand Down
1 change: 1 addition & 0 deletions src/go/rdctl/pkg/factoryreset/delete_data_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func DeleteData(ctx context.Context, appPaths paths.Paths, removeKubernetesCache
appPaths.AltAppHome,
appPaths.Config,
appPaths.Logs,
appPaths.OldUserData,
filepath.Join(homeDir, ".local", "state", "rancher-desktop"),
}

Expand Down
1 change: 1 addition & 0 deletions src/go/rdctl/pkg/factoryreset/factory_reset_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,6 @@ func getDirectoriesToDelete(keepSystemImages bool, appName string) ([]string, er
} else {
logrus.Errorf("Could not get AppData (roaming) folder: %s\n", err)
}
// The OldUserData directory is already deleted by deleting the Cache directory.
return dirs, nil
}
3 changes: 3 additions & 0 deletions src/go/rdctl/pkg/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type Paths struct {
Snapshots string `json:"snapshots,omitempty"`
// Directory containing user-managed containerd-shims
ContainerdShims string `json:"containerdShims,omitempty"`
// Previous location of Electron user data (e.g. cookies) up to Rancher Desktop 1.16.
// Current location is `$AppHome/electron` and does not need special treatment.
OldUserData string `json:"oldUserData,omitempty"`
}

var rdctlPathOverride string
Expand Down
1 change: 1 addition & 0 deletions src/go/rdctl/pkg/paths/paths_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func GetPaths(getResourcesPathFuncs ...func() (string, error)) (Paths, error) {
ExtensionRoot: filepath.Join(appHome, "extensions"),
Snapshots: filepath.Join(appHome, "snapshots"),
ContainerdShims: filepath.Join(appHome, "containerd-shims"),
OldUserData: filepath.Join(homeDir, "Library", "Application Support", "Rancher Desktop"),
}
paths.Logs = os.Getenv("RD_LOGS_DIR")
if paths.Logs == "" {
Expand Down
2 changes: 2 additions & 0 deletions src/go/rdctl/pkg/paths/paths_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestGetPaths(t *testing.T) {
ExtensionRoot: filepath.Join(homeDir, "Library", "Application Support", appName, "extensions"),
Snapshots: filepath.Join(homeDir, "Library", "Application Support", appName, "snapshots"),
ContainerdShims: filepath.Join(homeDir, "Library", "Application Support", appName, "containerd-shims"),
OldUserData: filepath.Join(homeDir, "Library", "Application Support", "Rancher Desktop"),
}
actualPaths, err := GetPaths(mockGetResourcesPath)
if err != nil {
Expand Down Expand Up @@ -64,6 +65,7 @@ func TestGetPaths(t *testing.T) {
ExtensionRoot: filepath.Join(homeDir, "Library", "Application Support", appName, "extensions"),
Snapshots: filepath.Join(homeDir, "Library", "Application Support", appName, "snapshots"),
ContainerdShims: filepath.Join(homeDir, "Library", "Application Support", appName, "containerd-shims"),
OldUserData: filepath.Join(homeDir, "Library", "Application Support", "Rancher Desktop"),
}
actualPaths, err := GetPaths(mockGetResourcesPath)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions src/go/rdctl/pkg/paths/paths_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func GetPaths(getResourcesPathFuncs ...func() (string, error)) (Paths, error) {
ExtensionRoot: filepath.Join(dataHome, appName, "extensions"),
Snapshots: filepath.Join(dataHome, appName, "snapshots"),
ContainerdShims: filepath.Join(dataHome, appName, "containerd-shims"),
OldUserData: filepath.Join(configHome, "Rancher Desktop"),
}
paths.Logs = os.Getenv("RD_LOGS_DIR")
if paths.Logs == "" {
Expand Down
2 changes: 2 additions & 0 deletions src/go/rdctl/pkg/paths/paths_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestGetPaths(t *testing.T) {
ExtensionRoot: filepath.Join(homeDir, ".local/share", appName, "extensions"),
Snapshots: filepath.Join(homeDir, ".local/share", appName, "snapshots"),
ContainerdShims: filepath.Join(homeDir, ".local/share", appName, "containerd-shims"),
OldUserData: filepath.Join(homeDir, ".config", "Rancher Desktop"),
}
actualPaths, err := GetPaths(mockGetResourcesPath)
if err != nil {
Expand Down Expand Up @@ -82,6 +83,7 @@ func TestGetPaths(t *testing.T) {
ExtensionRoot: filepath.Join(environment["XDG_DATA_HOME"], appName, "extensions"),
Snapshots: filepath.Join(environment["XDG_DATA_HOME"], appName, "snapshots"),
ContainerdShims: filepath.Join(environment["XDG_DATA_HOME"], appName, "containerd-shims"),
OldUserData: filepath.Join(environment["XDG_CONFIG_HOME"], "Rancher Desktop"),
}
actualPaths, err := GetPaths(mockGetResourcesPath)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions src/go/rdctl/pkg/paths/paths_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func GetPaths(getResourcesPathFuncs ...func() (string, error)) (Paths, error) {
ExtensionRoot: filepath.Join(localAppData, appName, "extensions"),
Snapshots: filepath.Join(localAppData, appName, "snapshots"),
ContainerdShims: filepath.Join(localAppData, appName, "containerd-shims"),
OldUserData: filepath.Join(localAppData, appName, "cache", "Rancher Desktop"),
}
paths.Logs = os.Getenv("RD_LOGS_DIR")
if paths.Logs == "" {
Expand Down
2 changes: 2 additions & 0 deletions src/go/rdctl/pkg/paths/paths_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestGetPaths(t *testing.T) {
ExtensionRoot: filepath.Join(homeDir, "AppData", "Local", appName, "extensions"),
Snapshots: filepath.Join(homeDir, "AppData", "Local", appName, "snapshots"),
ContainerdShims: filepath.Join(homeDir, "AppData", "Local", appName, "containerd-shims"),
OldUserData: filepath.Join(homeDir, "AppData", "Local", appName, "cache", "Rancher Desktop"),
}
actualPaths, err := GetPaths(mockGetResourcesPath)
if err != nil {
Expand Down Expand Up @@ -76,6 +77,7 @@ func TestGetPaths(t *testing.T) {
ExtensionRoot: filepath.Join(environment["LOCALAPPDATA"], appName, "extensions"),
Snapshots: filepath.Join(environment["LOCALAPPDATA"], appName, "snapshots"),
ContainerdShims: filepath.Join(environment["LOCALAPPDATA"], appName, "containerd-shims"),
OldUserData: filepath.Join(environment["LOCALAPPDATA"], appName, "cache", "Rancher Desktop"),
}
actualPaths, err := GetPaths(mockGetResourcesPath)
if err != nil {
Expand Down

0 comments on commit 5aea59b

Please sign in to comment.