Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Check repository and force update if it is not valid.
Vsevolod Stakhov committed 11 years ago
commit e4d5611d3fa1cda5bc289d0dfc20fb3e170b7b5d
parent 64cc0ef
1 file changed +18 -9
modified libpkg/repo/binary/update.c
@@ -846,17 +846,26 @@ pkg_repo_binary_update(struct pkg_repo *repo, bool force)
	dbdir = pkg_object_string(pkg_config_get("PKG_DBDIR"));
	pkg_debug(1, "PkgRepo: verifying update for %s", pkg_repo_name(repo));

-
	snprintf(filepath, sizeof(filepath), "%s/%s.meta", dbdir, pkg_repo_name(repo));
-
	if (stat(filepath, &st) != -1) {
-
		t = force ? 0 : st.st_mtime;
-
		got_meta = true;
+
	/* First of all, try to open and init repo and check whether it is fine */
+
	if (repo->ops->open(repo, R_OK|W_OK) != EPKG_OK) {
+
		pkg_debug(1, "PkgRepo: need forced update of %s", pkg_repo_name(repo));
+
		t = 0;
+
		force = true;
	}
+
	else {
+
		repo->ops->close(repo, false);
+
		snprintf(filepath, sizeof(filepath), "%s/%s.meta", dbdir, pkg_repo_name(repo));
+
		if (stat(filepath, &st) != -1) {
+
			t = force ? 0 : st.st_mtime;
+
			got_meta = true;
+
		}

-
	snprintf(filepath, sizeof(filepath), "%s/%s", dbdir,
-
		pkg_repo_binary_get_filename(pkg_repo_name(repo)));
-
	if (stat(filepath, &st) != -1) {
-
		if (!got_meta && !force)
-
			t = st.st_mtime;
+
		snprintf(filepath, sizeof(filepath), "%s/%s", dbdir,
+
			pkg_repo_binary_get_filename(pkg_repo_name(repo)));
+
		if (stat(filepath, &st) != -1) {
+
			if (!got_meta && !force)
+
				t = st.st_mtime;
+
		}
	}

	res = pkg_repo_binary_update_incremental(filepath, repo, &t, force);