From 6d593bb966f5deeef2084ac1beb706160bd8ac08 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 27 Nov 2018 00:55:26 +0100 Subject: [PATCH] When storing frame files in the database, use the base name, so that -d does not matter. --- main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index cf03900..ba44577 100644 --- a/main.cpp +++ b/main.cpp @@ -261,7 +261,7 @@ int main(int argc, char **argv) return ret; } -void load_frame_file(const char *filename, unsigned filename_idx, DB *db) +void load_frame_file(const char *filename, const string &basename, unsigned filename_idx, DB *db) { struct stat st; if (stat(filename, &st) == -1) { @@ -269,7 +269,7 @@ void load_frame_file(const char *filename, unsigned filename_idx, DB *db) exit(1); } - vector all_frames = db->load_frame_file(filename, st.st_size, filename_idx); + vector all_frames = db->load_frame_file(basename, st.st_size, filename_idx); if (!all_frames.empty()) { // We already had this cached in the database, so no need to look in the file. for (const DB::FrameOnDiskAndStreamIdx &frame : all_frames) { @@ -358,7 +358,7 @@ void load_frame_file(const char *filename, unsigned filename_idx, DB *db) size_t size = ftell(fp); fclose(fp); - db->store_frame_file(filename, size, all_frames); + db->store_frame_file(basename, size, all_frames); } void load_existing_frames() @@ -378,6 +378,7 @@ void load_existing_frames() return; } + vector frame_basenames; for ( ;; ) { errno = 0; dirent *de = readdir(dir); @@ -392,6 +393,7 @@ void load_existing_frames() if (de->d_type == DT_REG) { string filename = frame_dir + "/" + de->d_name; frame_filenames.push_back(filename); + frame_basenames.push_back(de->d_name); } if (progress.wasCanceled()) { @@ -410,7 +412,7 @@ void load_existing_frames() progress.setValue(2); for (size_t i = 0; i < frame_filenames.size(); ++i) { - load_frame_file(frame_filenames[i].c_str(), i, &db); + load_frame_file(frame_filenames[i].c_str(), frame_basenames[i], i, &db); progress.setValue(i + 3); if (progress.wasCanceled()) { exit(1); -- 2.39.2