mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
fix uses of config.get_path() to expect None
This commit is contained in:
@@ -29,7 +29,7 @@ class NominatimArgs:
|
||||
osm2pgsql_style=self.config.get_import_style_file(),
|
||||
threads=self.threads or default_threads,
|
||||
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,
|
||||
slim_index=self.config.TABLESPACE_OSM_INDEX,
|
||||
main_data=self.config.TABLESPACE_PLACE_DATA,
|
||||
|
||||
@@ -37,6 +37,6 @@ class SetupFreeze:
|
||||
|
||||
with connect(args.config.get_libpq_dsn()) as 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
|
||||
|
||||
@@ -42,10 +42,8 @@ def drop_update_tables(conn):
|
||||
conn.commit()
|
||||
|
||||
|
||||
def drop_flatnode_file(fname):
|
||||
def drop_flatnode_file(fpath):
|
||||
""" Remove the flatnode file if it exists.
|
||||
"""
|
||||
if fname:
|
||||
fpath = Path(fname)
|
||||
if fpath.exists():
|
||||
fpath.unlink()
|
||||
if fpath and fpath.exists():
|
||||
fpath.unlink()
|
||||
|
||||
@@ -174,7 +174,7 @@ def _quote_php_variable(var_type, config, conf_name):
|
||||
return 'false'
|
||||
|
||||
if var_type == Path:
|
||||
value = str(config.get_path(conf_name))
|
||||
value = str(config.get_path(conf_name) or '')
|
||||
else:
|
||||
value = getattr(config, conf_name)
|
||||
|
||||
|
||||
@@ -39,17 +39,17 @@ def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
|
||||
assert not temp_db_cursor.table_exists(table)
|
||||
|
||||
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):
|
||||
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):
|
||||
flatfile = tmp_path / 'flatnode.store'
|
||||
flatfile.write_text('Some content')
|
||||
|
||||
freeze.drop_flatnode_file(str(flatfile))
|
||||
freeze.drop_flatnode_file(flatfile)
|
||||
|
||||
assert not flatfile.exists()
|
||||
|
||||
Reference in New Issue
Block a user