@@ -85,14 +85,11 @@ def add_arguments_to_parser(parser):
8585 default = default_workspace ,
8686 required = False ,
8787 help = "Directory where CodeChecker can store analysis "
88- "result related data, such as the database. "
89- "(Cannot be specified at the same time with "
90- "'--sqlite' or '--config-directory'.)" )
88+ "result related data, such as the database." )
9189
9290 parser .add_argument ('-f' , '--config-directory' ,
9391 type = str ,
9492 dest = "config_directory" ,
95- default = default_workspace ,
9693 required = False ,
9794 help = "Directory where CodeChecker server should read "
9895 "server-specific configuration (such as "
@@ -169,9 +166,6 @@ def add_arguments_to_parser(parser):
169166 type = str ,
170167 dest = "sqlite" ,
171168 metavar = 'SQLITE_FILE' ,
172- default = os .path .join (
173- '<CONFIG_DIRECTORY>' ,
174- "config.sqlite" ),
175169 required = False ,
176170 help = "Path of the SQLite database file to use." )
177171
@@ -373,54 +367,24 @@ def arg_match(options):
373367 # is intended later on.
374368 delattr (args , 'not_host_only' )
375369
376- # --workspace and --sqlite cannot be specified either, as
377- # both point to a database location.
378- options = ['--sqlite' , '--workspace' ]
379- options_short = ['--sqlite' , '-w' ]
380- if set (arg_match (options )) == set (options ) or \
381- set (arg_match (options_short )) == set (options_short ):
382- parser .error ("argument --sqlite: not allowed with "
383- "argument --workspace" )
384-
385- # --workspace and --config-directory also aren't allowed together now,
386- # the latter one is expected to replace the earlier.
387- options = ['--config-directory' , '--workspace' ]
388- options_short = ['--config-directory' , '-w' ]
389- if set (arg_match (options )) == set (options ) or \
390- set (arg_match (options_short )) == set (options_short ):
391- parser .error ("argument --config-directory: not allowed with "
392- "argument --workspace" )
393-
394- # If workspace is specified, sqlite is workspace/config.sqlite
395- # and config_directory is the workspace directory.
396- if arg_match (['--workspace' , '-w' ]):
370+ # If config_directory is not specified, it will be the same
371+ # as the workspace directory.
372+ if not args .config_directory :
397373 args .config_directory = args .workspace
374+
375+ # If sqlite path is not specified, it will be set to
376+ # workspace/config.sqlite
377+ if not args .sqlite :
398378 args .sqlite = os .path .join (args .workspace ,
399379 'config.sqlite' )
400- setattr (args , 'dbdatadir' , os .path .join (args .workspace ,
401- 'pgsql_data' ))
402-
403- # Workspace should not exist as a Namespace key.
404- delattr (args , 'workspace' )
405-
406- if '<CONFIG_DIRECTORY>' in args .sqlite :
407- # Replace the placeholder variable with the actual value.
408- args .sqlite = args .sqlite .replace ('<CONFIG_DIRECTORY>' ,
409- args .config_directory )
410380
411381 # Convert relative sqlite file path to absolute.
412- if 'sqlite' in args :
413- args .sqlite = os .path .abspath (args .sqlite )
382+ args .sqlite = os .path .abspath (args .sqlite )
414383
415384 if 'postgresql' not in args :
416385 # Later called database modules need the argument to be actually
417386 # present, even though the default is suppressed in the optstring.
418387 setattr (args , 'postgresql' , False )
419-
420- # This is not needed by the database starter as we are
421- # running SQLite.
422- if 'dbdatadir' in args :
423- delattr (args , 'dbdatadir' )
424388 else :
425389 # If --postgresql is given, --sqlite is useless.
426390 delattr (args , 'sqlite' )
@@ -429,6 +393,10 @@ def arg_match(options):
429393 if "list" in args or "stop" in args or "stop_all" in args :
430394 setattr (args , "instance_manager" , True )
431395
396+ # Log directories
397+ LOG .info (f"Workspace directory: { args .workspace } " )
398+ LOG .info (f"Config directory: { args .config_directory } " )
399+
432400 # If everything is fine, do call the handler for the subcommand.
433401 return main (args )
434402
@@ -808,7 +776,7 @@ def __instance_management(args):
808776 if 'stop' in args and \
809777 not (i ['port' ] == args .view_port and
810778 os .path .abspath (i ['workspace' ]) ==
811- os .path .abspath (args .config_directory )):
779+ os .path .abspath (args .workspace )):
812780 continue
813781
814782 try :
@@ -836,7 +804,7 @@ def __reload_config(args):
836804 if 'reload' in args and \
837805 not (i ['port' ] == args .view_port and
838806 os .path .abspath (i ['workspace' ]) ==
839- os .path .abspath (args .config_directory )):
807+ os .path .abspath (args .workspace )):
840808 continue
841809
842810 try :
@@ -890,13 +858,6 @@ def server_init_start(args):
890858 if not host_check .check_zlib ():
891859 raise ModuleNotFoundError ("zlib is not available on the system!" )
892860
893- # WARNING
894- # In case of SQLite args.dbaddress default value is used
895- # for which the is_localhost should return true.
896- if is_localhost (args .dbaddress ) and \
897- not os .path .exists (args .config_directory ):
898- os .makedirs (args .config_directory )
899-
900861 # Make sure the SQLite file can be created if it not exists.
901862 if 'sqlite' in args and \
902863 not os .path .isdir (os .path .dirname (args .sqlite )):
@@ -907,7 +868,7 @@ def server_init_start(args):
907868 "option. The server will ask for users to authenticate!" )
908869
909870 context = webserver_context .get_context ()
910- context .codechecker_workspace = args .config_directory
871+ context .codechecker_workspace = args .workspace
911872 context .db_username = args .dbusername
912873
913874 environ = env .extend (context .path_env_extra ,
@@ -993,8 +954,8 @@ def server_init_start(args):
993954
994955 # Create the main database link from the arguments passed over the
995956 # command line.
996- cfg_dir = os .path .abspath (args .config_directory )
997- default_product_path = os .path .join (cfg_dir , 'Default.sqlite' )
957+ workspace_dir = os .path .abspath (args .workspace )
958+ default_product_path = os .path .join (workspace_dir , 'Default.sqlite' )
998959 create_default_product = 'sqlite' in args and \
999960 not os .path .exists (default_product_path )
1000961
@@ -1073,6 +1034,7 @@ def server_init_start(args):
10731034
10741035 try :
10751036 return server .start_server (args .config_directory ,
1037+ args .workspace ,
10761038 package_data ,
10771039 args .view_port ,
10781040 cfg_sql_server ,
@@ -1098,17 +1060,21 @@ def main(args):
10981060 Setup a logger server based on the configuration and
10991061 manage the CodeChecker server.
11001062 """
1101- workspace = (
1102- args .config_directory
1103- if "config_directory" in args and not hasattr (args , "instance_manager" )
1104- else None
1105- )
11061063
11071064 # Create workspace directory before logging is initialized.
1108- if workspace and not os .path .exists (args .config_directory ):
1109- LOG .info ("Creating non existing config directory: %s" ,
1110- args .config_directory )
1111- os .makedirs (args .config_directory )
1065+ workspace = None
1066+ if not hasattr (args , "instance_manager" ):
1067+ workspace = args .workspace
1068+
1069+ if not os .path .exists (workspace ):
1070+ LOG .info ("Creating non existing workspace directory: %s" ,
1071+ workspace )
1072+ os .makedirs (workspace )
1073+
1074+ if not os .path .exists (args .config_directory ):
1075+ LOG .info ("Creating non existing config directory: %s" ,
1076+ args .config_directory )
1077+ os .makedirs (args .config_directory )
11121078
11131079 with logger .LogCfgServer (
11141080 args .verbose if "verbose" in args else None , workspace = workspace
0 commit comments