Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ jobs:
runs-on: windows-2025

env:
OSMURL: https://download.geofabrik.de/europe/monaco-latest.osm.pbf
OSMURL: https://nominatim.org/ci-test-data/extract-tiny.osm.pbf

steps:
- uses: actions/checkout@v7
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
BUILD_TYPE: Release
CXXFLAGS: -pedantic -Wextra -Werror
PREFIX: /usr/local
OSMURL: https://download.geofabrik.de/europe/monaco-latest.osm.pbf
OSMFILE: monaco-latest.osm.pbf
OSMURL: https://nominatim.org/ci-test-data/test-country.osm.pbf
OSMFILE: test-country.osm.pbf

steps:
- uses: actions/checkout@v7
Expand Down
14 changes: 11 additions & 3 deletions scripts/osm2pgsql-replication
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ try:
from osmium.replication.utils import get_replication_header
from osmium.replication import newest_change_from_file
from osmium import WriteHandler
from osmium.version import pyosmium_release
except ImportError:
missing_modules.append('osmium')

Expand Down Expand Up @@ -301,6 +302,13 @@ class LegacyProperties:
self.db.conn.commit()


def make_replication_server(base_url):
repl = ReplicationServer(base_url)
repl.set_request_parameter(
'headers', {'User-Agent': f"osm2pgsql-replication (via pyosmium/{pyosmium_release})"})
return repl


def get_status_info(props, args):
results = {'status': 0}

Expand All @@ -310,7 +318,7 @@ def get_status_info(props, args):
results['server'] = {'base_url': base_url}
results['local'] = {'sequence': db_seq, 'timestamp': osm_date(db_ts)}

repl = ReplicationServer(base_url)
repl = make_replication_server(base_url)
state_info = repl.get_state_info()
if state_info is None:
# PyOsmium was unable to download the state information
Expand Down Expand Up @@ -442,7 +450,7 @@ def init(props, args):
if base_url is None or (seq is None and date is None):
raise DBError(1, f"File '{args.osm_file}' has no usable replication headers. Use '--server' instead.")

repl = ReplicationServer(base_url)
repl = make_replication_server(base_url)
if seq is None:
seq = repl.timestamp_to_sequence(date)
if seq is None:
Expand Down Expand Up @@ -506,7 +514,7 @@ def update(props, args):
LOG.info("Using replication service '%s'.", base_url)
local_db_age_sec = int((dt.datetime.now(dt.timezone.utc) - ts).total_seconds())

repl = ReplicationServer(base_url)
repl = make_replication_server(base_url)
current = repl.get_state_info()
if current is None:
raise DBError(1, f"Cannot reach the configured replication service '{base_url}'.\n"
Expand Down
3 changes: 3 additions & 0 deletions scripts/osm2pgsql-test-style
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class ReplicationServerMock:
numdiffs = int((max_size + 1023)/1024)
return min(self.state_infos[-1].sequence, start_id + numdiffs - 1)

def set_request_parameter(self, param, value):
pass

# Replication module is optional
_replication_path = Path(__file__, '..', 'osm2pgsql-replication').resolve()

Expand Down