Skip to content

Consolidate get_planet_time into store_file_utils and add unit tests - #543

Merged
hummeltech merged 2 commits into
masterfrom
GetPlanetTime
Nov 4, 2026
Merged

hummeltech merged 2 commits into
masterfrom
GetPlanetTime

Conversation

@hummeltech

Copy link
Copy Markdown
Collaborator
  • Unify duplicate timestamp lookups from render_old.c and store_file.c into store_file_utils.c.
  • Fix path generation by introducing explicit slash separation for style-specific planet timestamp files (<tile_dir>/<xmlname>/file).
  • Replace non-thread-safe ctime calls in render_old.c with ctime_r.
  • Remove side-effect logging from lower-level storage helpers.
  • Add comprehensive Catch2 unit test coverage for get_planet_time style lookups and fallback behaviors.

- Unify duplicate timestamp lookups from render_old.c and store_file.c
  into store_file_utils.c.
- Fix path generation by introducing explicit slash separation for
  style-specific planet timestamp files (`<tile_dir>/<xmlname>/file`).
- Replace non-thread-safe ctime calls in render_old.c with ctime_r.
- Remove side-effect logging from lower-level storage helpers.
- Add comprehensive Catch2 unit test coverage for get_planet_time style
  lookups and fallback behaviors.
Comment thread src/render_old.c
if (planet_timestamp == 0) {
planet_timestamp = get_planet_time(tile_dir);
planet_timestamp = get_planet_time(tile_dir, mapname_passed ? mapname : NULL);
char time_buf[26];
Comment thread src/render_old.c
g_logger(G_LOG_LEVEL_MESSAGE, "Planet file updated at %s", time_buf);
} else {
g_logger(G_LOG_LEVEL_MESSAGE, "Overwriting planet file update to %s", strtok(ctime(&planet_timestamp), "\n"));
char time_buf[26];
Comment thread src/store_file_utils.c
time_t get_planet_time(const char *tile_dir, const char *xmlname)
{
struct stat st_stat;
char filename[PATH_MAX];
Comment thread src/store_file_utils.c

/* Use map-specific timestamp file */
if (xmlname && xmlname[0] != '\0') {
snprintf(filename, sizeof(filename), "%s/%s/%s", tile_dir, xmlname, PLANET_TIMESTAMP);
Comment thread src/store_file_utils.c
}

/* Fallback to global timestamp file */
snprintf(filename, sizeof(filename), "%s/%s", tile_dir, PLANET_TIMESTAMP);
@hummeltech
hummeltech merged commit ad9bd01 into master Nov 4, 2026
41 of 43 checks passed
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.

2 participants