Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add indices to the remote repo after updating
Bryan Drewery committed 14 years ago
commit 0c8f37730f5f2f1be10085eda9d81aa9ee06d13d
parent 8229cc52908131c4c15d5268ec744bf14404cfb5
3 files changed +55 -0
modified libpkg/pkg.h
@@ -618,6 +618,11 @@ int pkgdb_open(struct pkgdb **db, pkgdb_t type);
 */
void pkgdb_close(struct pkgdb *db);

+
/**
+
 * Initialize the local cache of the remote database with indicies
+
 */
+
int pkgdb_remote_init(struct pkgdb *db, const char *reponame);
+

/** 
 * Dump the content of the database in yaml format
 * only to use when mtree will be deprecated
modified libpkg/pkgdb.c
@@ -543,6 +543,33 @@ pkgdb_init(sqlite3 *sdb)
	return (sql_exec(sdb, sql));
}

+
/**
+
 * Initialize the local cache of the remote database with indicies
+
 */
+
int
+
pkgdb_remote_init(struct pkgdb *db, const char *repo)
+
{
+
	struct sbuf *sql = NULL;
+
	const char *reponame = NULL;
+
	int ret;
+
	const char init_sql[] = ""
+
	"BEGIN;"
+
	"CREATE INDEX '%s'.deps_origin on deps(origin);"
+
	"COMMIT;"
+
	;
+

+
	if ((reponame = pkgdb_get_reponame(db, repo)) == NULL) {
+
		return (EPKG_FATAL);
+
	}
+

+
	sql = sbuf_new_auto();
+
	sbuf_printf(sql, init_sql, reponame);
+

+
	ret = sql_exec(db->sqlite, sbuf_data(sql));
+
	sbuf_delete(sql);
+
	return (ret);
+
}
+

int
pkgdb_open(struct pkgdb **db_p, pkgdb_t type)
{
modified pkg/update.c
@@ -49,6 +49,27 @@

static int update_from_remote_repo(const char *name, const char *url);

+
/* Add indexes to the repo */
+
static int
+
remote_add_indexes(const char *reponame)
+
{
+
	struct pkgdb *db = NULL;
+
	int ret = EPKG_FATAL;
+

+
	if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK)
+
		goto cleanup;
+

+
	/* Initialize the remote remote */
+
	if (pkgdb_remote_init(db, reponame) != EPKG_OK)
+
		goto cleanup;
+

+
	ret = EPKG_OK;
+
cleanup:
+
	if (db)
+
		pkgdb_close(db);
+
	return (ret);
+
}
+

static int
update_from_remote_repo(const char *name, const char *url)
{
@@ -133,6 +154,8 @@ update_from_remote_repo(const char *name, const char *url)

	rename(repofile_unchecked, repofile);

+
	if ((rc = remote_add_indexes(name)) != EPKG_OK)
+
		goto cleanup;
cleanup:
	if (a != NULL)
		archive_read_finish(a);