Repository navigation
Consolidate get_planet_time into store_file_utils and add unit tests - #543
Merged
Merged
Conversation
- 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.
| 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]; |
| 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]; |
| time_t get_planet_time(const char *tile_dir, const char *xmlname) | ||
| { | ||
| struct stat st_stat; | ||
| char filename[PATH_MAX]; |
|
|
||
| /* Use map-specific timestamp file */ | ||
| if (xmlname && xmlname[0] != '\0') { | ||
| snprintf(filename, sizeof(filename), "%s/%s/%s", tile_dir, xmlname, PLANET_TIMESTAMP); |
| } | ||
|
|
||
| /* Fallback to global timestamp file */ | ||
| snprintf(filename, sizeof(filename), "%s/%s", tile_dir, PLANET_TIMESTAMP); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<tile_dir>/<xmlname>/file).