Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata Provider: Improve startup times by avoiding directory scanning #1089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/backend/providers/pegasus_metadata/PegasusFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void apply_filter(FileFilter& filter, SearchContext& sctx)

const bool has_valid_regex = !filter.include.regex.pattern().isEmpty() && filter.include.regex.isValid();
const bool needs_scan = !filter.include.extensions.empty() || has_valid_regex;
if (!needs_scan)
if (!AppSettings::general.verify_files || !needs_scan)
return;

constexpr auto entry_filters_files = QDir::Files | QDir::NoDotAndDotDot;
Expand Down
10 changes: 10 additions & 0 deletions src/backend/providers/pegasus_metadata/PegasusProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ std::vector<QString> find_metafiles_in(const QString& dir_path)

std::vector<QString> result;

QDir dir(dir_path);

// look for standalone files first, to avoid reading the entire directory
if (dir.exists("metadata.pegasus.txt")) {
return { QDir::cleanPath(dir_path + QDir::separator() + "metadata.pegasus.txt") };
} else if (dir.exists("metadata.txt")) {
return { QDir::cleanPath(dir_path + QDir::separator() + "metadata.txt") };
}

// else look for wildcard metadata files
QDirIterator dir_it(dir_path, dir_filters, dir_flags);
while (dir_it.hasNext()) {
dir_it.next();
Expand Down