Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
fetch: add a cleanup function
Baptiste Daroussin committed 3 years ago
commit fb0fbeb5c5d1ac8e3aa3a702fdadef0f1b5b6507
parent cd3a5f3
3 files changed +10 -5
modified libpkg/fetch.c
@@ -53,36 +53,43 @@ static struct fetcher fetchers [] = {
		"tcp",
		tcp_open,
		NULL,
+
		fh_close,
	},
	{
		"ssh",
		ssh_open,
		NULL,
+
		fh_close,
	},
	{
		"pkg+https",
		fetch_open,
		fh_close,
+
		NULL,
	},
	{
		"pkg+http",
		fetch_open,
		fh_close,
+
		NULL,
	},
	{
		"https",
		fetch_open,
		fh_close,
+
		NULL,
	},
	{
		"http",
		fetch_open,
		fh_close,
+
		NULL,
	},
	{
		"file",
		file_open,
		fh_close,
+
		NULL,
	},
};

modified libpkg/pkg_config.c
@@ -1481,10 +1481,8 @@ pkg_repo_free(struct pkg_repo *r)
	free(r->pubkey);
	free(r->fingerprints);
	pkg_repo_meta_free(r->meta);
-
	if (r->ssh != NULL) {
-
		fprintf(r->ssh, "quit\n");
-
		pclose(r->ssh);
-
	}
+
	if (r->fetcher != NULL && r->fetcher->cleanup != NULL)
+
		r->fetcher->cleanup(r);
	tll_free_and_free(r->env, pkg_kv_free);
	free(r);
}
modified libpkg/private/pkg.h
@@ -182,6 +182,7 @@ struct fetcher {
	const char *scheme;
	int (*open)(struct pkg_repo *, struct url *, off_t *);
	int (*close)(struct pkg_repo *);
+
	int (*cleanup)(struct pkg_repo *);
};
struct pkg_message;
typedef tll(struct pkg_message *) messages_t;
@@ -520,7 +521,6 @@ struct pkg_repo {
	signature_t signature_type;
	char *fingerprints;
	FILE *fh;
-
	FILE *ssh;
	bool silent;

	pkghash *trusted_fp;