char* description;
char* baseurl;
+ // Refresh Interval
+ time_t refresh;
+
// Key
char* key;
if (baseurl)
pakfire_repo_set_baseurl(repo, baseurl);
+ // Refresh Interval
+ const char* refresh = pakfire_config_get(config, *section, "refresh", NULL);
+ if (refresh)
+ repo->appdata->refresh = pakfire_string_parse_interval(refresh);
+
// mirrors
const char* mirrors = pakfire_config_get(config, *section, "mirrors", NULL);
if (mirrors)
0, NULL, 0, PAKFIRE_TRANSFER_NOPROGRESS);
}
-static int pakfire_repo_download_metadata(struct pakfire_repo* repo, const char* path, const int force) {
+static int pakfire_repo_download_metadata(struct pakfire_repo* repo, const char* path, int force) {
+ // Fetch refresh interval
+ time_t refresh = repo->appdata->refresh;
+
+ // Use a default value if unset
+ if (refresh < 0)
+ refresh = REFRESH_AGE_METADATA;
+
+ // If the refresh interval is set to zero, we will always force a refresh
+ if (refresh == 0)
+ force = 1;
+
// Check if this needs to be refreshed
if (!force) {
time_t age = pakfire_path_age(path);
- if (age > 0 && age < REFRESH_AGE_METADATA) {
+ if (age > 0 && age < refresh) {
DEBUG(repo->pakfire, "Skip refreshing metadata which is %lds old\n", age);
return 0;
}
}
}
+static struct pakfire_repo_appdata* pakfire_repo_setup_appdata(struct pakfire_repo* repo) {
+ struct pakfire_repo_appdata* appdata = NULL;
+
+ // Allocate appdata
+ appdata = calloc(1, sizeof(*repo->appdata));
+ if (!appdata)
+ return NULL;
+
+ // Refresh Interval: Set to invalid
+ appdata->refresh = -1;
+
+ return appdata;
+}
+
PAKFIRE_EXPORT int pakfire_repo_create(struct pakfire_repo** repo,
struct pakfire* pakfire, const char* name) {
int r = 1;
}
// Allocate repository appdata
- rep->appdata = rep->repo->appdata = calloc(1, sizeof(*rep->appdata));
+ rep->appdata = rep->repo->appdata = pakfire_repo_setup_appdata(rep);
if (!rep->appdata) {
- ERROR(rep->pakfire, "Could not allocate repo appdata\n");
+ ERROR(rep->pakfire, "Could not setup repository appdata for %s\n", name);
goto ERROR;
}
}
}
+ // Refresh Interval
+ char* refresh = pakfire_string_format_interval(repo->appdata->refresh);
+ if (refresh) {
+ r = pakfire_config_set(config, section, "refresh", refresh);
+ free(refresh);
+
+ if (r) {
+ ERROR(repo->pakfire, "Could not set refresh interval: %m\n");
+ goto ERROR;
+ }
+ }
+
// Mirror List
const char* mirrorlist = pakfire_repo_get_mirrorlist_url(repo);
if (mirrorlist) {