Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ impl App {
if !trash_paths.is_empty() {
tasks.push(self.operation(Operation::Delete { paths: trash_paths }));
}
tasks.push(self.rescan_recents());
Task::batch(tasks)
}

Expand Down Expand Up @@ -1383,11 +1384,6 @@ impl App {
commands.push(self.update_config());
}
}

if matches!(op, Operation::RemoveFromRecents { .. }) {
commands.push(self.rescan_recents());
}

self.complete_operations.insert(id, op);
}
}
Expand All @@ -1405,6 +1401,8 @@ impl App {
commands.push(self.rescan_operation_selection(op_sel));
// Manually rescan any trash tabs after any operation is completed
commands.push(self.rescan_trash());
// Manually rescan any Recents tabs after any operation is completed
commands.push(self.rescan_recents());

Task::batch(commands)
}
Expand Down Expand Up @@ -1451,6 +1449,8 @@ impl App {
}
// Manually rescan any trash tabs after any operation is completed
tasks.push(self.rescan_trash());
// Manually rescan any Recents tabs after any operation is completed
tasks.push(self.rescan_recents());
Task::batch(tasks)
}

Expand Down Expand Up @@ -4323,6 +4323,7 @@ impl Application for App {
&last_name,
'.',
),
self.rescan_recents(),
]);
return Task::batch(tasks);
}
Expand All @@ -4347,6 +4348,7 @@ impl Application for App {
Message::RestoreFromTrash(entity_opt) => {
let mut trash_items = Vec::new();
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
let mut tasks = Vec::new();
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity)
&& let Some(items) = tab.items_opt()
{
Expand All @@ -4361,8 +4363,10 @@ impl Application for App {
}
}
if !trash_items.is_empty() {
return self.operation(Operation::Restore { items: trash_items });
tasks.push(self.operation(Operation::Restore { items: trash_items }));
}
tasks.push(self.rescan_recents());
return Task::batch(tasks);
}
Message::ScrollTab(scroll_speed) => {
let entity = self.tab_model.active();
Expand Down Expand Up @@ -6971,6 +6975,17 @@ impl Application for App {
"trash needs to be rescanned but sending message failed: {e:?}"
);
}

// Rescan on any event. Keeps the Recents tab synchronised
if should_rescan
&& let Err(e) = futures::executor::block_on(async {
output.send(Message::RescanRecents).await
})
{
log::warn!(
"recents needs to be rescanned but sending message failed: {e:?}"
);
}
}
Err(e) => {
log::warn!("failed to watch trash bin for changes: {e:?}");
Expand Down
13 changes: 13 additions & 0 deletions src/operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ impl Operation {
}
Self::Rename { from, to } => {
let controller_clone = controller.clone();
let to_clone = to.clone();

compio::runtime::spawn(async move {
let controller = controller_clone;
Expand All @@ -1127,6 +1128,18 @@ impl Operation {
compio::fs::rename(&from, &to)
.await
.map_err(|e| OperationError::from_err(e, &controller))?;

let _ = tokio::task::spawn_blocking(move || {
recently_used_xbel::update_recently_used(
&to_clone,
"com.system76.CosmicFiles".to_string(),
"cosmic-files".to_string(),
None,
)
})
.await
.map_err(|e| OperationError::from_err(e, &controller))?;

Result::<_, OperationError>::Ok(OperationSelection {
ignored: vec![from],
selected: vec![to],
Expand Down