prefer ID_{MODEL|VENDOR} to what we can dig out of sysfs
authorDavid Zeuthen <davidz@redhat.com>
Fri, 13 Feb 2009 18:00:02 +0000 (13:00 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 13 Feb 2009 18:00:02 +0000 (13:00 -0500)
Recent udev versions actually provide this.

src/devkit-disks-device.c

index 9ced38d..58c655c 100644 (file)
@@ -1840,17 +1840,23 @@ update_drive_properties (DevkitDisksDevice *device)
                                  */
                                 vendor = sysfs_get_string (s, "vendor");
                                 if (vendor != NULL) {
-                                        g_free (device->priv->info.drive_vendor);
                                         g_strstrip (vendor);
-                                        device->priv->info.drive_vendor = _dupv8 (vendor);
+                                        /* Don't overwrite what we set earlier from ID_VENDOR */
+                                        if (device->priv->info.drive_vendor == NULL) {
+                                                g_free (device->priv->info.drive_vendor);
+                                                device->priv->info.drive_vendor = _dupv8 (vendor);
+                                        }
                                         g_free (vendor);
                                 }
 
                                 model = sysfs_get_string (s, "model");
                                 if (model != NULL) {
-                                        g_free (device->priv->info.drive_model);
                                         g_strstrip (model);
-                                        device->priv->info.drive_model = _dupv8 (model);
+                                        /* Don't overwrite what we set earlier from ID_MODEL */
+                                        if (device->priv->info.drive_model == NULL) {
+                                                g_free (device->priv->info.drive_model);
+                                                device->priv->info.drive_model = _dupv8 (model);
+                                        }
                                         g_free (model);
                                 }