[file_collection] fix GLOB_NOCHECK condition

Fixes #1281
pull/1285/head
Tim Stack 2 months ago
parent 82bb1169c9
commit b6581c2c76

@ -649,10 +649,9 @@ file_collection::expand_filename(
}
auto filename_key = loo.loo_filename.empty() ? path : loo.loo_filename;
auto glob_flags = lnav::filesystem::is_glob(path) ? 0 : GLOB_NOCHECK;
if (glob(path.c_str(), glob_flags, nullptr, gl.inout()) == 0) {
int lpc;
auto glob_flags = lnav::filesystem::is_glob(path) ? GLOB_NOCHECK : 0;
auto glob_rc = glob(path.c_str(), glob_flags, nullptr, gl.inout());
if (glob_rc == 0) {
if (gl->gl_pathc == 1 /*&& gl.gl_matchc == 0*/) {
/* It's a pattern that doesn't match any files
* yet, allow it through since we'll load it in
@ -696,7 +695,7 @@ file_collection::expand_filename(
}
std::lock_guard<std::mutex> lg(REALPATH_CACHE_MUTEX);
for (lpc = 0; lpc < (int) gl->gl_pathc; lpc++) {
for (size_t lpc = 0; lpc < gl->gl_pathc; lpc++) {
auto path_str = std::string(gl->gl_pathv[lpc]);
auto iter = REALPATH_CACHE.find(path_str);
@ -768,6 +767,8 @@ file_collection::expand_filename(
}
}
}
} else if (glob_rc != GLOB_NOMATCH) {
log_error("glob(%s) failed -- %s", path.c_str(), strerror(errno));
}
}

@ -3077,9 +3077,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
= file_path_str.substr(0, colon_index);
file_loc = vis_line_t(scan_res.value());
} else {
log_warning(
"failed to parse line number from file path "
"with colon: %s",
log_info(
"did not parse line number from file path with colon: %s",
file_path_str.c_str());
}
}

@ -81,6 +81,17 @@ check_error_output "no error for nonexistent-host?" <<EOF
error: unable to open file: nonexistent-host: -- failed to ssh to host: ...
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
nonexistent-host:${test_dir}/logfile_access_log.*
sed -e "s|ssh:.*|...|g" `test_err_filename` | head -1 \
> test_remote.err
mv test_remote.err `test_err_filename`
check_error_output "no error for nonexistent-host?" <<EOF
error: unable to open file: nonexistent-host: -- failed to ssh to host: ...
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
localhost:nonexistent-file

Loading…
Cancel
Save