socsvn commit: r253581 - soc2013/mattbw/backend

mattbw at FreeBSD.org mattbw at FreeBSD.org
Thu Jun 27 00:09:03 UTC 2013


Author: mattbw
Date: Thu Jun 27 00:09:03 2013
New Revision: 253581
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253581

Log:
  stop the screaming if a repository that does not exist is asked for, amongst other things

Modified:
  soc2013/mattbw/backend/db.c
  soc2013/mattbw/backend/iterate.c

Modified: soc2013/mattbw/backend/db.c
==============================================================================
--- soc2013/mattbw/backend/db.c	Wed Jun 26 23:53:54 2013	(r253580)
+++ soc2013/mattbw/backend/db.c	Thu Jun 27 00:09:03 2013	(r253581)
@@ -95,27 +95,25 @@
 		 int load_flags,
 		 pkg_func_ptr emitter)
 {
-	gboolean	success;
-	gchar         **strv;
-	const gchar    *name;
-	const gchar    *version;
+	gboolean	query_success;
+	gboolean	split_success;
 	const gchar    *arch;
 	const gchar    *data;
+	const gchar    *name;
+	const gchar    *version;
+	gchar         **strv;
 
-	success = FALSE;
+	query_success = FALSE;
+	split_success = FALSE;
 	strv = NULL;
 
-	success = split_id(id, &strv, &name, &version, &arch, &data);
-	if (success == FALSE)
+	split_success = split_id(id, &strv, &name, &version, &arch, &data);
+	if (split_success == FALSE)
 		pk_backend_error_code(backend,
 				      PK_ERROR_ENUM_PACKAGE_ID_INVALID,
 				      "invalid package id");
 	else {
 		/*
-		 * If we got a repository name, then we want to make sure it
-		 * corresponds to a real repository.
-		 */
-		/*
 		 * If the PackageID has a repository specified (even if it's
 		 * "installed" i.e. currently installed package), running
 		 * "get_details_query" directly should handle remote/local
@@ -127,29 +125,29 @@
 		 */
 		if (data == NULL)
 			/* Try local database first. */
-			success = db_query_split(name,
-						 version,
-						 arch,
-						 "installed",
-						 backend,
-						 db,
-						 load_flags,
-						 emitter);
-		if (success == FALSE)
-			success = db_query_split(name, version, arch, data,
+			query_success = db_query_split(name,
+						       version,
+						       arch,
+						       "installed",
+						       backend,
+						       db,
+						       load_flags,
+						       emitter);
+		if (query_success == FALSE)
+			query_success = db_query_split(name, version, arch, data,
 					  backend, db, load_flags, emitter);
 		/*
 		 * Assume any error is due to not finding packages. At time
 		 * of writing this is true, but may change.
 		 */
-		if (success == FALSE)
+		if (query_success == FALSE)
 			pk_backend_error_code(backend,
 					    PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
 					      "package not found");
 		g_strfreev(strv);
 	}
 
-	return success;
+	return query_success;
 }
 
 /*
@@ -174,13 +172,24 @@
 	gboolean	success;
 
 	success = FALSE;
+	it = NULL;
 
 	/* Are we doing a local query? */
+	/*
+	 * If we got a repository name, then we want to make sure it
+	 * corresponds to a real repository.
+	 */
 	if (g_strcmp0(reponame, "installed") == 0)
 		it = pkgdb_query(db, name, MATCH_EXACT);
-	else
+	else if (pkg_repo_find_ident(reponame) != NULL)
 		it = pkgdb_rquery(db, name, MATCH_EXACT, reponame);
-	if (it)
+	else
+		pk_backend_error_code(backend,
+				      PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
+				      "no such repository");
+
+
+	if (it != NULL)
 		success = iterate_id_matches(it,
 					     backend,
 					     name,

Modified: soc2013/mattbw/backend/iterate.c
==============================================================================
--- soc2013/mattbw/backend/iterate.c	Wed Jun 26 23:53:54 2013	(r253580)
+++ soc2013/mattbw/backend/iterate.c	Thu Jun 27 00:09:03 2013	(r253581)
@@ -67,12 +67,12 @@
 		err = EPKG_FATAL;
 	} else {
 		for (HASH_FOR(err, pkgdb_it_next, iterator, &pkg, fetch_flags)) {
-			if (err == EPKG_OK && try_id_match(pkg,
-							   name,
-							   version,
-							   arch,
-							   data,
-							   &match_id) == TRUE) {
+			if (try_id_match(pkg,
+					   name,
+					   version,
+					   arch,
+					   data,
+					   &match_id) == TRUE) {
 				found = TRUE;
 				iterate_f(pkg, match_id, backend);
 			}


More information about the svn-soc-all mailing list