From 1d3337dc57fd50a64e8d03512df7220f2dea1b5f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 2 Nov 2018 16:42:20 +1300 Subject: [PATCH] scriptindex: Improve error handling for LOAD action If we successfully opened the file but hit an error reading from it we would have reported the partial contents read so far instead of the filename in the error message. (cherry picked from commit 069810b80ef586857a6bd530c87262f04d81c4ee) --- xapian-applications/omega/scriptindex.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xapian-applications/omega/scriptindex.cc b/xapian-applications/omega/scriptindex.cc index 3cbe5de2d..8b93ad34f 100644 --- a/xapian-applications/omega/scriptindex.cc +++ b/xapian-applications/omega/scriptindex.cc @@ -755,13 +755,15 @@ badhex: break; case Action::LOAD: { bool truncated = false; + string filename = std::move(value); // FIXME: Use NOATIME if we own the file or are root. - if (!load_file(value, action.get_num_arg(), NOCACHE, + if (!load_file(filename, action.get_num_arg(), NOCACHE, value, truncated)) { report_location(DIAG_ERROR, fname, line_no); - cerr << "Couldn't load file '" << value << "': " + cerr << "Couldn't load file '" << filename << "': " << strerror(errno) << endl; value.resize(0); + break; } if (!truncated) break; } -- 2.11.4.GIT