diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 554b4c5..722f7d4 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -148,6 +148,28 @@ fn cleanup_profile_history_files(profile_path: &Path, profile_id: &str) -> Clean remove_sidecar_files(&file_path); } + let sessions_directory = profile_path.join("Sessions"); + match cleanup_sessions_directory(&sessions_directory) { + Ok(session_deleted) => { + if session_deleted { + deleted_files.push("Sessions".to_string()); + } else { + skipped_files.push("Sessions".to_string()); + } + } + Err(error) => { + return CleanupHistoryResult { + profile_id: profile_id.to_string(), + deleted_files, + skipped_files, + error: Some(format!( + "Failed to clean {}: {error}", + sessions_directory.display() + )), + }; + } + } + CleanupHistoryResult { profile_id: profile_id.to_string(), deleted_files, @@ -164,3 +186,21 @@ fn remove_sidecar_files(path: &Path) { } } } + +fn cleanup_sessions_directory(path: &Path) -> Result { + if !path.is_dir() { + return Ok(false); + } + + let mut deleted_any = false; + for entry in path.read_dir()? { + let entry = entry?; + let entry_path = entry.path(); + if entry_path.is_file() { + fs::remove_file(&entry_path)?; + deleted_any = true; + } + } + + Ok(deleted_any) +} diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs index abf1f50..a54bb30 100644 --- a/src-tauri/src/models.rs +++ b/src-tauri/src/models.rs @@ -83,6 +83,7 @@ pub struct HistoryCleanupSummary { pub history: CleanupFileStatus, pub top_sites: CleanupFileStatus, pub visited_links: CleanupFileStatus, + pub sessions: CleanupFileStatus, } #[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] diff --git a/src-tauri/src/scanner.rs b/src-tauri/src/scanner.rs index 34f1f63..7d17e05 100644 --- a/src-tauri/src/scanner.rs +++ b/src-tauri/src/scanner.rs @@ -101,6 +101,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option { cleanup.history == CleanupFileStatus::Found || cleanup.top_sites == CleanupFileStatus::Found || cleanup.visited_links == CleanupFileStatus::Found + || cleanup.sessions == CleanupFileStatus::Found }) .count(); @@ -195,6 +196,7 @@ fn scan_history_cleanup_status(profile_path: &Path) -> HistoryCleanupSummary { history: cleanup_file_status(&profile_path.join("History")), top_sites: cleanup_file_status(&profile_path.join("Top Sites")), visited_links: cleanup_file_status(&profile_path.join("Visited Links")), + sessions: cleanup_sessions_status(&profile_path.join("Sessions")), } } @@ -206,6 +208,18 @@ fn cleanup_file_status(path: &Path) -> CleanupFileStatus { } } +fn cleanup_sessions_status(path: &Path) -> CleanupFileStatus { + let Ok(entries) = path.read_dir() else { + return CleanupFileStatus::Missing; + }; + + if entries.flatten().any(|entry| entry.path().is_file()) { + CleanupFileStatus::Found + } else { + CleanupFileStatus::Missing + } +} + fn resolve_profile_avatar( _root: &Path, profile_path: &Path, diff --git a/src/components/browser-data/HistoryCleanupList.vue b/src/components/browser-data/HistoryCleanupList.vue index dfb2d4b..806d446 100644 --- a/src/components/browser-data/HistoryCleanupList.vue +++ b/src/components/browser-data/HistoryCleanupList.vue @@ -23,6 +23,7 @@ const selectableProfiles = computed(() => profile.historyCleanup.history, profile.historyCleanup.topSites, profile.historyCleanup.visitedLinks, + profile.historyCleanup.sessions, ]), ), ); @@ -52,6 +53,7 @@ function isSelectable(profile: ProfileSummary) { profile.historyCleanup.history, profile.historyCleanup.topSites, profile.historyCleanup.visitedLinks, + profile.historyCleanup.sessions, ]); } @@ -96,6 +98,7 @@ function hasAnyHistoryFile(statuses: CleanupFileStatus[]) {
History
Top Sites
Visited Links
+
Sessions
Action
@@ -143,6 +146,11 @@ function hasAnyHistoryFile(statuses: CleanupFileStatus[]) { {{ statusLabel(profile.historyCleanup.visitedLinks) }}
+
+ + {{ statusLabel(profile.historyCleanup.sessions) }} + +