Skip to content

Commit 68dd377

Browse files
committed
Remove last.state.txt from imposm dir
1 parent 250a8a3 commit 68dd377

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

images/tiler-imposm/start.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,23 @@ function updateData() {
245245

246246
# Step 2: Handle last.state.txt if OVERWRITE_STATE is enabled
247247
if [ "$OVERWRITE_STATE" = "true" ]; then
248-
log_message "Overwriting last.state.txt..."
249-
timestamp=$(date -u +"%Y-%m-%dT%H\\:%M\\:%SZ")
250-
cat <<EOF > "$local_last_state_path"
248+
log_message "Overwriting last.state.txt with sequenceNumber=${SEQUENCE_NUMBER:-0}..."
249+
# Clean old downloaded diffs to force imposm to re-download from the new sequence number
250+
log_message "Cleaning old diff files in ${DIFF_DIR} to avoid stale state..."
251+
find "$DIFF_DIR" -type f ! -name "last.state.txt" -delete 2>/dev/null
252+
timestamp=$(date -u +"%Y-%m-%dT%H\\:%M\\:%SZ")
253+
cat <<EOF > "$local_last_state_path"
251254
timestamp=${timestamp}
252255
sequenceNumber=${SEQUENCE_NUMBER:-0}
253256
replicationUrl=${REPLICATION_URL}
254257
EOF
258+
else
259+
if [ -f "$local_last_state_path" ]; then
260+
current_seq=$(grep -oP 'sequenceNumber=\K\d+' "$local_last_state_path" 2>/dev/null || echo "unknown")
261+
log_message "Using existing last.state.txt (sequenceNumber=${current_seq}). Set OVERWRITE_STATE=true to override with SEQUENCE_NUMBER=${SEQUENCE_NUMBER:-0}."
262+
else
263+
log_message "WARNING: No last.state.txt found and OVERWRITE_STATE=false. Imposm may not know where to start replication."
264+
fi
255265
fi
256266

257267
# Step 3: Start uploader in background and store its PID

0 commit comments

Comments
 (0)