diff --git a/Source/CLI/CLI.cpp b/Source/CLI/CLI.cpp index 2b70862b..c879eea6 100644 --- a/Source/CLI/CLI.cpp +++ b/Source/CLI/CLI.cpp @@ -124,7 +124,7 @@ void __stdcall Event_CallBackFunction(unsigned char* Data_Content, size_t Data_S //-------------------------------------------------------------------------- CLI::CLI() : watch_folder_user(NULL), use_as_user(-1), use_daemon(false), asynchronous(false), - force_analyze(false), full_report(false), include_hidden_files(false), mil_analyze(true), + force_analyze(false), full_report(false), no_database(false), include_hidden_files(false), mil_analyze(true), watch_folder_recursive(true), create_policy_mode(false), file_information(false), plugins_list_mode(false), list_watch_folders_mode(false), no_needs_files_mode(false), list_mode(false), fixer(false) @@ -146,6 +146,9 @@ void __stdcall Event_CallBackFunction(unsigned char* Data_Content, size_t Data_S return CLI_RETURN_ERROR; } + if (no_database) + MCL.set_no_database(no_database); + if (!no_needs_files_mode) { // If no filenames (and no options) @@ -1045,6 +1048,12 @@ void __stdcall Event_CallBackFunction(unsigned char* Data_Content, size_t Data_S force_analyze = force; } + //-------------------------------------------------------------------------- + void CLI::set_no_database(bool no_db) + { + no_database = no_db; + } + //-------------------------------------------------------------------------- void CLI::set_mil_analyze(bool analyze) { diff --git a/Source/CLI/CLI.h b/Source/CLI/CLI.h index bfe097a1..83ee2f48 100644 --- a/Source/CLI/CLI.h +++ b/Source/CLI/CLI.h @@ -51,6 +51,7 @@ namespace MediaConch int set_user_to_use(const std::string& user); int set_compression_mode(const std::string& mode_str); void set_force_analyze(bool force); + void set_no_database(bool no_db); void set_mil_analyze(bool analyze); void set_asynchronous(bool async); void set_create_policy_mode(); @@ -103,6 +104,7 @@ namespace MediaConch bool use_daemon; bool asynchronous; bool force_analyze; + bool no_database; bool full_report; bool include_hidden_files; bool mil_analyze; diff --git a/Source/CLI/CommandLine_Parser.cpp b/Source/CLI/CommandLine_Parser.cpp index 29d19523..18185601 100644 --- a/Source/CLI/CommandLine_Parser.cpp +++ b/Source/CLI/CommandLine_Parser.cpp @@ -163,10 +163,14 @@ static void change_short_options_to_long(std::string& argument) argument = "--help=Advanced"; if (argument=="-v") argument = "--version"; + + // Main short options if (argument=="-f") argument = "--force"; if (argument=="-nmil") argument = "--nomilanalyze"; + if (argument=="-ndb") + argument = "--nodatabase"; // Backward compatibility if (argument=="-tc") @@ -272,6 +276,7 @@ int Parse(MediaConch::CLI* cli, std::string& argument) OPTION("--full", Full) OPTION("--includehidden", IncludeHidden) OPTION("--nomilanalyze", NoMilAnalyze) + OPTION("--nodatabase", NoDatabase) OPTION("--async", Asynchronous) OPTION("--pluginslist", PluginsList) OPTION("--useplugin", UsePlugin) @@ -547,6 +552,14 @@ CL_OPTION(NoMilAnalyze) return CLI_RETURN_NONE; } +//--------------------------------------------------------------------------- +CL_OPTION(NoDatabase) +{ + (void)argument; + cli->set_no_database(true); + return CLI_RETURN_NONE; +} + //--------------------------------------------------------------------------- CL_OPTION(Asynchronous) { diff --git a/Source/CLI/CommandLine_Parser.h b/Source/CLI/CommandLine_Parser.h index 006c88b8..2a72290b 100644 --- a/Source/CLI/CommandLine_Parser.h +++ b/Source/CLI/CommandLine_Parser.h @@ -51,6 +51,7 @@ CL_OPTION(Force); CL_OPTION(Full); CL_OPTION(IncludeHidden); CL_OPTION(NoMilAnalyze); +CL_OPTION(NoDatabase); CL_OPTION(Asynchronous); CL_OPTION(UsePlugin); CL_OPTION(PluginsList); diff --git a/Source/CLI/Help.cpp b/Source/CLI/Help.cpp index d2b8cdd4..8a656a2f 100644 --- a/Source/CLI/Help.cpp +++ b/Source/CLI/Help.cpp @@ -193,6 +193,8 @@ int Help_Advanced() TEXTOUT(" Full MediaInfo report (needed by some policies)"); TEXTOUT("--NoMilAnalyze, -nmil"); TEXTOUT(" Do not analyze with MediaInfoLib"); + TEXTOUT("--NoDatabase, -ndb"); + TEXTOUT(" Do not read or write to the persistant database"); TEXTOUT("--Async=yes, -as"); TEXTOUT(" Analyze asynchronously the files,"); TEXTOUT(" need to launch again the command to have the result"); diff --git a/Source/Common/Core.cpp b/Source/Common/Core.cpp index 7dd47499..950e3779 100644 --- a/Source/Common/Core.cpp +++ b/Source/Common/Core.cpp @@ -79,6 +79,7 @@ Core::Core() : policies(this), reports(this) watch_folders_manager = new WatchFoldersManager(this); policies.create_values_from_csv(); compression_mode = MediaConchLib::compression_ZLib; + no_database = false; } Core::~Core() @@ -154,18 +155,21 @@ void Core::load_plugins_configuration() void Core::load_database() { #ifdef HAVE_SQLITE - std::string db_path; - if (!config || config->get("SQLite_Path", db_path) < 0) - db_path = get_database_path(); + if (!no_database) + { + std::string db_path; + if (!config || config->get("SQLite_Path", db_path) < 0) + db_path = get_database_path(); - db = new SQLLiteReport; + db = new SQLLiteReport; - ((Database*)db)->set_database_directory(db_path); - db->set_database_filename(database_name); - if (db->init_report() < 0) - { - delete db; - db = NULL; + ((Database*)db)->set_database_directory(db_path); + db->set_database_filename(database_name); + if (db->init_report() < 0) + { + delete db; + db = NULL; + } } #endif if (!db) @@ -264,6 +268,18 @@ void Core::set_compression_mode(MediaConchLib::compression compress) compression_mode = compress; } +//--------------------------------------------------------------------------- +void Core::set_no_database(bool ndb) +{ + no_database = ndb; + if (db) + { + delete db; + db = NULL; + } + load_database(); +} + //--------------------------------------------------------------------------- int Core::get_ui_poll_request() const { diff --git a/Source/Common/Core.h b/Source/Common/Core.h index 207930b0..546a17f0 100644 --- a/Source/Common/Core.h +++ b/Source/Common/Core.h @@ -164,6 +164,7 @@ class Core void set_implementation_verbosity(const std::string& verbosity); const std::string& get_implementation_verbosity(); void set_compression_mode(MediaConchLib::compression compress); + void set_no_database(bool no_database); int get_ui_poll_request() const; int get_ui_database_path(std::string& path) const; bool is_using_daemon() const; @@ -227,8 +228,9 @@ class Core std::map implementation_options; Scheduler *scheduler; PluginsManager *plugins_manager; - WatchFoldersManager *watch_folders_manager; + WatchFoldersManager *watch_folders_manager; MediaConchLib::compression compression_mode; + bool no_database; bool has_outcome_fail(const std::string& report); diff --git a/Source/Common/MediaConchLib.cpp b/Source/Common/MediaConchLib.cpp index 76988dad..22f489f6 100644 --- a/Source/Common/MediaConchLib.cpp +++ b/Source/Common/MediaConchLib.cpp @@ -828,6 +828,13 @@ void MediaConchLib::set_compression_mode(compression compress) core->set_compression_mode(compress); } +//--------------------------------------------------------------------------- +void MediaConchLib::set_no_database(bool no_database) +{ + if (core) + core->set_no_database(no_database); +} + //--------------------------------------------------------------------------- int MediaConchLib::get_ui_poll_request() const { diff --git a/Source/Common/MediaConchLib.h b/Source/Common/MediaConchLib.h index 25e48430..24dba771 100644 --- a/Source/Common/MediaConchLib.h +++ b/Source/Common/MediaConchLib.h @@ -406,6 +406,7 @@ class MediaConchLib void load_plugins_configuration(); void set_plugins_configuration_file(const std::string& file); void set_compression_mode(compression compress); + void set_no_database(bool no_database); int get_ui_poll_request() const; int get_ui_database_path(std::string& path) const;