Skip to content

Commit

Permalink
Change cache path.
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-graj committed Mar 28, 2023
1 parent 073d2a7 commit 6019e08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Binary file removed demo.gif
Binary file not shown.
13 changes: 9 additions & 4 deletions src/entity/satellite.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ static gboolean orbits_changed_phys = FALSE;

static gboolean recache = FALSE;

static const char *CACHE_FILENAME = ".sat_cache";
static const char *CACHE_FILENAME = ".orbvis_cache";
static gchar *cache_filepath;

static GThreadPool *thread_pool;
static guint32 *thread_pool_indices_sync;
Expand Down Expand Up @@ -156,6 +157,8 @@ void satellite_init(void)

guint num_proc = g_get_num_processors();
thread_pool = g_thread_pool_new(satellites_calc_pos, NULL, MIN(num_proc, MAX_THREAD_TIC), TRUE, NULL);

cache_filepath = g_build_filename(g_get_user_cache_dir(), CACHE_FILENAME, NULL);
}

void alloc_orbit_arrays(void)
Expand Down Expand Up @@ -194,6 +197,8 @@ void satellite_deinit(void)
dealloc_orbit_arrays();

g_thread_pool_free(thread_pool, TRUE, FALSE);

g_free(cache_filepath);
}

void satellites_filter(void)
Expand Down Expand Up @@ -237,13 +242,13 @@ int sc_compare(const void *a, const void *b, void *udata)

void satellite_clear_cache(void)
{
g_remove(CACHE_FILENAME);
g_remove(cache_filepath);
recache = TRUE;
}

void save_satellite_cache(void)
{
FILE *cache = fopen(CACHE_FILENAME, "w");
FILE *cache = fopen(cache_filepath, "w");
gint64 epoch_ms = system_epoch_ms();
fwrite(&epoch_ms, 8, 1, cache);
fwrite(&dl_multi.handles[DL_SATCAT].size, 8, 1, cache);
Expand All @@ -267,7 +272,7 @@ void satellites_get(void)
dl_multi_perform(&dl_multi);
save_satellite_cache();
} else {
FILE *cache = fopen(CACHE_FILENAME, "r");
FILE *cache = fopen(cache_filepath, "r");
if (!cache) {
dl_multi_perform(&dl_multi);
save_satellite_cache();
Expand Down

0 comments on commit 6019e08

Please sign in to comment.