Improve ISO detection mechanism
Upstream commit: 71cf18b07b830f7966db Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
		
							parent
							
								
									465459b048
								
							
						
					
					
						commit
						86f8b9e50e
					
				| @ -0,0 +1,51 @@ | |||||||
|  | From 71cf18b07b830f7966dbd6b6705c0f9cddb5c587 Mon Sep 17 00:00:00 2001 | ||||||
|  | From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com> | ||||||
|  | Date: Tue, 5 Nov 2019 15:56:28 +0100 | ||||||
|  | Subject: [PATCH] db: Take the media's volume size into account when sorting | ||||||
|  |  the medias | ||||||
|  | MIME-Version: 1.0 | ||||||
|  | Content-Type: text/plain; charset=UTF-8 | ||||||
|  | Content-Transfer-Encoding: 8bit | ||||||
|  | 
 | ||||||
|  | If volume-size is not taken into account, when dealing with identical | ||||||
|  | ISOs, we may end up wrongly matching an entry that has its volume-size | ||||||
|  | with one which doesn't have the value, simply because the one which does | ||||||
|  | not have the value may be declared first the in XML entry. | ||||||
|  | 
 | ||||||
|  | Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> | ||||||
|  | Reviewed-by; Daniel P. Berrangé <berrange@redhat.com> | ||||||
|  | ---
 | ||||||
|  |  osinfo/osinfo_db.c | 14 ++++++++++++-- | ||||||
|  |  1 file changed, 12 insertions(+), 2 deletions(-) | ||||||
|  | 
 | ||||||
|  | diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
 | ||||||
|  | index 328b251a..e2845df2 100644
 | ||||||
|  | --- a/osinfo/osinfo_db.c
 | ||||||
|  | +++ b/osinfo/osinfo_db.c
 | ||||||
|  | @@ -538,11 +538,21 @@ static gint media_volume_compare(gconstpointer a, gconstpointer b)
 | ||||||
|  |          /* Order doesn't matter then */ | ||||||
|  |          return 0; | ||||||
|  |   | ||||||
|  | -    if (strstr(volume_a, volume_b) != NULL)
 | ||||||
|  | +    if (strstr(volume_a, volume_b) != NULL) {
 | ||||||
|  | +        gint64 volume_size_a = osinfo_media_get_volume_size(media_a);
 | ||||||
|  | +        gint64 volume_size_b = osinfo_media_get_volume_size(media_b);
 | ||||||
|  | +
 | ||||||
|  | +        if (volume_size_a != -1 && volume_size_b == -1)
 | ||||||
|  | +            return -1;
 | ||||||
|  | +
 | ||||||
|  | +        if (volume_size_b != -1 && volume_size_a == -1)
 | ||||||
|  | +            return 1;
 | ||||||
|  | +
 | ||||||
|  |          return -1; | ||||||
|  | -    else
 | ||||||
|  | +    } else {
 | ||||||
|  |          /* Sub-string comes later */ | ||||||
|  |          return 1; | ||||||
|  | +    }
 | ||||||
|  |  } | ||||||
|  |   | ||||||
|  |  static gboolean compare_media(OsinfoMedia *media, | ||||||
|  | -- 
 | ||||||
|  | 2.23.0 | ||||||
|  | 
 | ||||||
| @ -3,12 +3,13 @@ | |||||||
| Summary: A library for managing OS information for virtualization | Summary: A library for managing OS information for virtualization | ||||||
| Name: libosinfo | Name: libosinfo | ||||||
| Version: 1.6.0 | Version: 1.6.0 | ||||||
| Release: 1%{?dist}%{?extra_release} | Release: 2%{?dist}%{?extra_release} | ||||||
| License: LGPLv2+ | License: LGPLv2+ | ||||||
| Source: https://releases.pagure.io/%{name}/%{name}-%{version}.tar.gz | Source: https://releases.pagure.io/%{name}/%{name}-%{version}.tar.gz | ||||||
| URL: https://libosinfo.org/ | URL: https://libosinfo.org/ | ||||||
| 
 | 
 | ||||||
| ### Patches ### | ### Patches ### | ||||||
|  | Patch0001: 0001-db-Take-the-media-s-volume-size-into-account-when-so.patch | ||||||
| 
 | 
 | ||||||
| BuildRequires: gettext-devel | BuildRequires: gettext-devel | ||||||
| BuildRequires: glib2-devel | BuildRequires: glib2-devel | ||||||
| @ -98,6 +99,9 @@ fi | |||||||
| %{_datadir}/vala/vapi/libosinfo-1.0.vapi | %{_datadir}/vala/vapi/libosinfo-1.0.vapi | ||||||
| 
 | 
 | ||||||
| %changelog | %changelog | ||||||
|  | * Fri Nov 08 2019 Fabiano Fidêncio <fidencio@redhat.com> - 1.6.0-2 | ||||||
|  | - Improve ISO detection mechanism | ||||||
|  | 
 | ||||||
| * Fri Jul 26 2019 Fabiano Fidêncio <fidencio@redhat.com> - 1.6.0-1 | * Fri Jul 26 2019 Fabiano Fidêncio <fidencio@redhat.com> - 1.6.0-1 | ||||||
| - Update to 1.6.0 release | - Update to 1.6.0 release | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user