[libhif/f21] Do not crash when file:///tmp exists, but file:///tmp/repodata does not

Richard Hughes rhughes at fedoraproject.org
Tue Feb 3 16:42:09 UTC 2015


commit 6b805d210ff438f00cea9673c7965343e1349d4e
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Feb 3 16:41:03 2015 +0000

    Do not crash when file:///tmp exists, but file:///tmp/repodata does not

 ...led-local-source-does-not-exist-do-not-ad.patch |   84 +++++++++++++++-----
 libhif.spec                                        |    5 +-
 2 files changed, 67 insertions(+), 22 deletions(-)
---
diff --git a/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch b/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch
index 88defd1..b586a4f 100644
--- a/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch
+++ b/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch
@@ -1,23 +1,28 @@
-From 43188b72c5b88e0ec427dc0b24acae5f91c72390 Mon Sep 17 00:00:00 2001
-From: Richard Hughes <richard at hughsie.com>
-Date: Tue, 3 Feb 2015 15:15:49 +0000
-Subject: [PATCH] If the enabled local source does not exist do not add it to
- the sack
-
-You can reproduce the problem setting baseurl=file:///notgoingtoexist in an
-enabled .repo file.
-
-Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1135740
----
- libhif/hif-sack.c   |  7 +++++++
- libhif/hif-source.c | 17 ++++++++++++++++-
- 2 files changed, 23 insertions(+), 1 deletion(-)
-
+diff --git a/data/tests/yum.repos.d/local.repo b/data/tests/yum.repos.d/local.repo
+index 4773cc0..0c25d48 100644
+--- a/data/tests/yum.repos.d/local.repo
++++ b/data/tests/yum.repos.d/local.repo
+@@ -1,6 +1,6 @@
+ [local]
+ name=Local
+-baseurl=file:///tmp/repo
++baseurl=file:///tmp
+ enabled=1
+ gpgcheck=0
+ metadata_expire=0
 diff --git a/libhif/hif-sack.c b/libhif/hif-sack.c
-index 5f86c58..0aab526 100644
+index 5f86c58..550fa1f 100644
 --- a/libhif/hif-sack.c
 +++ b/libhif/hif-sack.c
-@@ -93,6 +93,13 @@ hif_sack_add_source (HySack sack,
+@@ -82,6 +82,7 @@ hif_sack_add_source (HySack sack,
+ 			if (g_error_matches (error_local,
+ 					     HIF_ERROR,
+ 					     HIF_ERROR_CANNOT_FETCH_SOURCE)) {
++				hif_source_set_enabled (src, HIF_SOURCE_ENABLED_NONE);
+ 				g_warning ("Skipping refresh of %s: %s",
+ 					   hif_source_get_id (src),
+ 					   error_local->message);
+@@ -93,6 +94,13 @@ hif_sack_add_source (HySack sack,
  		}
  	}
  
@@ -31,8 +36,24 @@ index 5f86c58..0aab526 100644
  	/* done */
  	if (!hif_state_done (state, error))
  		return FALSE;
+diff --git a/libhif/hif-self-test.c b/libhif/hif-self-test.c
+index 23ee721..7ba9b3b 100644
+--- a/libhif/hif-self-test.c
++++ b/libhif/hif-self-test.c
+@@ -878,8 +878,9 @@ hif_repos_func (void)
+ 	/* try to refresh local repo */
+ 	hif_state_reset (state);
+ 	ret = hif_source_update (src, HIF_SOURCE_UPDATE_FLAG_NONE, state, &error);
+-	g_assert_no_error (error);
+-	g_assert (ret);
++	g_assert_error (error, HIF_ERROR, HIF_ERROR_CANNOT_FETCH_SOURCE);
++	g_assert (!ret);
++	g_clear_error (&error);
+ 
+ 	/* try to check local repo that will not exist */
+ 	hif_state_reset (state);
 diff --git a/libhif/hif-source.c b/libhif/hif-source.c
-index b38fcf4..bef2ba3 100644
+index b38fcf4..36dd735 100644
 --- a/libhif/hif-source.c
 +++ b/libhif/hif-source.c
 @@ -960,7 +960,22 @@ hif_source_check (HifSource *source,
@@ -59,6 +80,27 @@ index b38fcf4..bef2ba3 100644
  	}
  
  	/* Yum metadata */
--- 
-2.1.0
-
+@@ -1220,19 +1235,16 @@ hif_source_update (HifSource *source,
+ 	gint64 timestamp_new = 0;
+ 	_cleanup_error_free_ GError *error_local = NULL;
+ 
+-	/* cannot change DVD contents */
+-	if (priv->kind == HIF_SOURCE_KIND_MEDIA) {
++	/* cannot change DVD or local contents */
++	if (priv->kind == HIF_SOURCE_KIND_MEDIA ||
++	    priv->kind == HIF_SOURCE_KIND_LOCAL) {
+ 		g_set_error_literal (error,
+ 				     HIF_ERROR,
+-				     HIF_ERROR_SOURCE_NOT_AVAILABLE,
++				     HIF_ERROR_CANNOT_FETCH_SOURCE,
+ 				     "Cannot update read-only source");
+ 		return FALSE;
+ 	}
+ 
+-	/* do not refresh local repos */
+-	if (priv->kind == HIF_SOURCE_KIND_LOCAL)
+-		return TRUE;
+-
+ 	/* this needs to be set */
+ 	if (priv->location_tmp == NULL) {
+ 		g_set_error (error,
diff --git a/libhif.spec b/libhif.spec
index 2d2ca2a..da0faef 100644
--- a/libhif.spec
+++ b/libhif.spec
@@ -1,7 +1,7 @@
 Summary:   Simple package library built on top of hawkey and librepo
 Name:      libhif
 Version:   0.1.8
-Release:   3%{?dist}
+Release:   4%{?dist}
 License:   LGPLv2+
 URL:       https://github.com/hughsie/libhif
 Source0:   http://people.freedesktop.org/~hughsient/releases/libhif-%{version}.tar.xz
@@ -67,6 +67,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libhif*.la
 %{_datadir}/gir-1.0/*.gir
 
 %changelog
+* Tue Feb 03 2015 Richard Hughes <richard at hughsie.com> 0.1.8-4
+- Do not crash when file:///tmp exists, but file:///tmp/repodata does not
+
 * Tue Feb 03 2015 Richard Hughes <richard at hughsie.com> 0.1.8-3
 - Do not add the source to the sack if it does not exist, which fixes a crash
   for repo files with things like baseurl=file:///notgoingtoexist


More information about the scm-commits mailing list