From owner-svn-soc-all@FreeBSD.ORG Thu Jun 27 00:09:03 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BC947A30 for ; Thu, 27 Jun 2013 00:09:03 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 9ED4A1826 for ; Thu, 27 Jun 2013 00:09:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5R093GX007959 for ; Thu, 27 Jun 2013 00:09:03 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5R093gR007950 for svn-soc-all@FreeBSD.org; Thu, 27 Jun 2013 00:09:03 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 27 Jun 2013 00:09:03 GMT Message-Id: <201306270009.r5R093gR007950@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253581 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jun 2013 00:09:03 -0000 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); }