Skip to content

Commit f748f71

Browse files
authored
fix(desktop): handle symlinked persona pack directories (#859)
1 parent 1fe7bf2 commit f748f71

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎desktop/src-tauri/src/managed_agents/personas.rs‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -882,12 +882,20 @@ pub fn uninstall_persona_pack(app: &AppHandle, pack_id: &str) -> Result<(), Stri
882882
));
883883
}
884884

885-
// Remove pack directory
885+
// Remove pack directory (or symlink)
886886
let packs = packs_dir(app)?;
887887
let pack_dir = packs.join(pack_id);
888888
if pack_dir.exists() {
889-
fs::remove_dir_all(&pack_dir)
890-
.map_err(|e| format!("failed to remove pack directory: {e}"))?;
889+
let is_symlink = fs::symlink_metadata(&pack_dir)
890+
.map(|m| m.file_type().is_symlink())
891+
.unwrap_or(false);
892+
if is_symlink {
893+
fs::remove_file(&pack_dir)
894+
.map_err(|e| format!("failed to remove pack symlink: {e}"))?;
895+
} else {
896+
fs::remove_dir_all(&pack_dir)
897+
.map_err(|e| format!("failed to remove pack directory: {e}"))?;
898+
}
891899
}
892900

893901
// Remove pack PersonaRecords
@@ -909,10 +917,11 @@ pub fn list_installed_packs(app: &AppHandle) -> Result<Vec<PackSummary>, String>
909917

910918
for entry in fs::read_dir(&packs).map_err(|e| format!("failed to read packs dir: {e}"))? {
911919
let entry = entry.map_err(|e| format!("dir entry error: {e}"))?;
912-
if !entry.file_type().map(|t| t.is_dir()).unwrap_or(false) {
920+
let pack_dir = entry.path();
921+
// Use stat (follows symlinks) rather than lstat so symlinked packs are recognised.
922+
if !pack_dir.is_dir() {
913923
continue;
914924
}
915-
let pack_dir = entry.path();
916925
if let Ok(resolved) = sprout_persona::resolve::resolve_pack(&pack_dir) {
917926
summaries.push(PackSummary {
918927
id: resolved.id,

0 commit comments

Comments
 (0)