1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 03:12:12 +00:00

FileManager: Remove clicked breadcrumbs for non-existing directories

This fixes #8204.

In the case that we just navigated up from a directory because it was
deleted, we can detect that easily by checking if the child directory
exists, and then remove the relevant breadcrumbs immediately.

However, it's harder to notice if a child directory for a breadcrumb
is deleted at another time. Previously, clicking that breadcrumb would
crash, but now we check to see if the directory it points to actually
exists. If it doesn't, we pop that breadcrumb and any after it, off
of the breadcrumbbar.

This may not be the ideal solution - maybe it should detect that the
directory is gone automatically - but it works and doesn't involve
managing additional directory watchers.
This commit is contained in:
Sam Atkins 2021-06-24 15:43:05 +01:00 committed by Ali Mohammad Pur
parent d8e0535116
commit f5e63f785a
2 changed files with 24 additions and 13 deletions

View file

@ -272,11 +272,11 @@ FileSystemModel::FileSystemModel(String root_path, Mode mode)
auto canonical_event_path = LexicalPath::canonicalized_path(event.event_path);
if (m_root_path.starts_with(canonical_event_path)) {
// Deleted directory contains our root, so navigate to our nearest parent.
auto new_path = LexicalPath(m_root_path).dirname();
while (!Core::File::is_directory(new_path))
new_path = LexicalPath(new_path).dirname();
auto new_path = LexicalPath(m_root_path).parent();
while (!Core::File::is_directory(new_path.string()))
new_path = new_path.parent();
set_root_path(new_path);
set_root_path(new_path.string());
} else if (node.parent) {
refresh_node(*node.parent);
}