fix uses of config.get_path() to expect None

This commit is contained in:
Sarah Hoffmann
2022-07-03 18:36:33 +02:00
parent c4928c646d
commit aaf2b6032e
5 changed files with 9 additions and 11 deletions

View File

@@ -29,7 +29,7 @@ class NominatimArgs:
osm2pgsql_style=self.config.get_import_style_file(), osm2pgsql_style=self.config.get_import_style_file(),
threads=self.threads or default_threads, threads=self.threads or default_threads,
dsn=self.config.get_libpq_dsn(), dsn=self.config.get_libpq_dsn(),
flatnode_file=str(self.config.get_path('FLATNODE_FILE')), flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''),
tablespaces=dict(slim_data=self.config.TABLESPACE_OSM_DATA, tablespaces=dict(slim_data=self.config.TABLESPACE_OSM_DATA,
slim_index=self.config.TABLESPACE_OSM_INDEX, slim_index=self.config.TABLESPACE_OSM_INDEX,
main_data=self.config.TABLESPACE_PLACE_DATA, main_data=self.config.TABLESPACE_PLACE_DATA,

View File

@@ -37,6 +37,6 @@ class SetupFreeze:
with connect(args.config.get_libpq_dsn()) as conn: with connect(args.config.get_libpq_dsn()) as conn:
freeze.drop_update_tables(conn) freeze.drop_update_tables(conn)
freeze.drop_flatnode_file(str(args.config.get_path('FLATNODE_FILE'))) freeze.drop_flatnode_file(args.config.get_path('FLATNODE_FILE'))
return 0 return 0

View File

@@ -42,10 +42,8 @@ def drop_update_tables(conn):
conn.commit() conn.commit()
def drop_flatnode_file(fname): def drop_flatnode_file(fpath):
""" Remove the flatnode file if it exists. """ Remove the flatnode file if it exists.
""" """
if fname: if fpath and fpath.exists():
fpath = Path(fname) fpath.unlink()
if fpath.exists():
fpath.unlink()

View File

@@ -174,7 +174,7 @@ def _quote_php_variable(var_type, config, conf_name):
return 'false' return 'false'
if var_type == Path: if var_type == Path:
value = str(config.get_path(conf_name)) value = str(config.get_path(conf_name) or '')
else: else:
value = getattr(config, conf_name) value = getattr(config, conf_name)

View File

@@ -39,17 +39,17 @@ def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
assert not temp_db_cursor.table_exists(table) assert not temp_db_cursor.table_exists(table)
def test_drop_flatnode_file_no_file(): def test_drop_flatnode_file_no_file():
freeze.drop_flatnode_file('') freeze.drop_flatnode_file(None)
def test_drop_flatnode_file_file_already_gone(tmp_path): def test_drop_flatnode_file_file_already_gone(tmp_path):
freeze.drop_flatnode_file(str(tmp_path / 'something.store')) freeze.drop_flatnode_file(tmp_path / 'something.store')
def test_drop_flatnode_file_delte(tmp_path): def test_drop_flatnode_file_delte(tmp_path):
flatfile = tmp_path / 'flatnode.store' flatfile = tmp_path / 'flatnode.store'
flatfile.write_text('Some content') flatfile.write_text('Some content')
freeze.drop_flatnode_file(str(flatfile)) freeze.drop_flatnode_file(flatfile)
assert not flatfile.exists() assert not flatfile.exists()