Skip to content

Fix curl error handling and add cache cleanup script#6

Open
AlexCherrypi wants to merge 1 commit intoaugmentedlogic:masterfrom
AlexCherrypi:pr/bugfixes-and-improvements
Open

Fix curl error handling and add cache cleanup script#6
AlexCherrypi wants to merge 1 commit intoaugmentedlogic:masterfrom
AlexCherrypi:pr/bugfixes-and-improvements

Conversation

@AlexCherrypi
Copy link
Copy Markdown

Fix curl error handling and add cache cleanup script

Bug Fixes in TileProxy.php

  1. Fixed curl error checking after curl_close() (critical bug)

    • curl_errno() and curl_error() return invalid data after curl_close() is called
    • Now stores error information before closing the curl handle
  2. Added HTTP status code validation

    • Previously only checked for curl transport errors
    • Now also validates HTTP response codes (e.g., 404, 503 from tile servers)
    • Includes response body in error message for debugging
  3. Added CURLOPT_FOLLOWLOCATION

    • Some tile servers may redirect requests
  4. Fixed double slash in cache paths

    • Changed default paths from ../cache/ to ../cache

New Feature

  1. Cache cleanup script (scripts/cleanup-cache.sh)
    • Deletes tiles older than 13 days
    • Limits each style folder to max 1GB (removes oldest files first)
    • Removes empty directories
    • Cron example: 0 3 */5 * * /path/to/cleanup-cache.sh /path/to/cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant