[rygel] core,tracker: Fix criticals on empty XDG_*_HOME variables
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,tracker: Fix criticals on empty XDG_*_HOME variables
- Date: Wed, 24 Aug 2016 19:41:42 +0000 (UTC)
commit 7902579475a68191a02b0c2b95f904c7af3f21fa
Author: Jens Georg <mail jensge org>
Date: Wed Aug 24 21:37:29 2016 +0200
core,tracker: Fix criticals on empty XDG_*_HOME variables
Signed-off-by: Jens Georg <mail jensge org>
https://bugzilla.gnome.org/show_bug.cgi?id=730910
src/librygel-core/rygel-base-configuration.vala | 6 ++--
src/librygel-core/rygel-configuration.vala | 6 ++--
src/librygel-core/rygel-meta-config.vala | 31 +++++++++++++------
.../rygel-tracker-category-all-container.vala | 16 ++++++----
.../tracker/rygel-tracker-item-factory.vala | 2 +-
5 files changed, 37 insertions(+), 24 deletions(-)
---
diff --git a/src/librygel-core/rygel-base-configuration.vala b/src/librygel-core/rygel-base-configuration.vala
index 88459f9..e911945 100644
--- a/src/librygel-core/rygel-base-configuration.vala
+++ b/src/librygel-core/rygel-base-configuration.vala
@@ -67,15 +67,15 @@ public class Rygel.BaseConfiguration : Rygel.Configuration, Object {
throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
}
- public virtual string get_video_upload_folder () throws GLib.Error {
+ public virtual string? get_video_upload_folder () throws GLib.Error {
throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
}
- public virtual string get_music_upload_folder () throws GLib.Error {
+ public virtual string? get_music_upload_folder () throws GLib.Error {
throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
}
- public virtual string get_picture_upload_folder () throws GLib.Error {
+ public virtual string? get_picture_upload_folder () throws GLib.Error {
throw new ConfigurationError.NO_VALUE_SET (_("Not implemented"));
}
diff --git a/src/librygel-core/rygel-configuration.vala b/src/librygel-core/rygel-configuration.vala
index 7501a81..3513f23 100644
--- a/src/librygel-core/rygel-configuration.vala
+++ b/src/librygel-core/rygel-configuration.vala
@@ -94,11 +94,11 @@ public interface Rygel.Configuration : GLib.Object {
public abstract string get_media_engine () throws GLib.Error;
- public abstract string get_video_upload_folder () throws GLib.Error;
+ public abstract string? get_video_upload_folder () throws GLib.Error;
- public abstract string get_music_upload_folder () throws GLib.Error;
+ public abstract string? get_music_upload_folder () throws GLib.Error;
- public abstract string get_picture_upload_folder () throws GLib.Error;
+ public abstract string? get_picture_upload_folder () throws GLib.Error;
public abstract bool get_enabled (string section) throws GLib.Error;
diff --git a/src/librygel-core/rygel-meta-config.vala b/src/librygel-core/rygel-meta-config.vala
index 1cc9224..c2762a9 100644
--- a/src/librygel-core/rygel-meta-config.vala
+++ b/src/librygel-core/rygel-meta-config.vala
@@ -264,8 +264,8 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
return val;
}
- public string get_video_upload_folder () throws GLib.Error {
- unowned string default = Environment.get_user_special_dir
+ public string? get_video_upload_folder () throws GLib.Error {
+ unowned string? default = Environment.get_user_special_dir
(UserDirectory.VIDEOS);
var value = default;
@@ -275,11 +275,15 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
} catch (GLib.Error err) { }
}
- return value.replace ("@VIDEOS@", default);
+ if (value != null && default != null) {
+ return value.replace ("@VIDEOS@", default);
+ }
+
+ return null;
}
- public string get_music_upload_folder () throws GLib.Error {
- unowned string default = Environment.get_user_special_dir
+ public string? get_music_upload_folder () throws GLib.Error {
+ unowned string? default = Environment.get_user_special_dir
(UserDirectory.MUSIC);
var value = default;
@@ -290,11 +294,15 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
} catch (GLib.Error err) {};
}
- return value.replace ("@MUSIC@", default);
+ if (value != null && default != null) {
+ return value.replace ("@MUSIC@", default);
+ }
+
+ return null;
}
- public string get_picture_upload_folder () throws GLib.Error {
- unowned string default = Environment.get_user_special_dir
+ public string? get_picture_upload_folder () throws GLib.Error {
+ unowned string? default = Environment.get_user_special_dir
(UserDirectory.PICTURES);
var value = default;
@@ -304,9 +312,12 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
} catch (GLib.Error err) {};
}
- return value.replace ("@PICTURES@", default);
- }
+ if (value != null && default != null) {
+ return value.replace ("@PICTURES@", default);
+ }
+ return null;
+ }
public bool get_enabled (string section) throws GLib.Error {
bool val = true;
diff --git a/src/plugins/tracker/rygel-tracker-category-all-container.vala
b/src/plugins/tracker/rygel-tracker-category-all-container.vala
index 36628a2..af86d42 100644
--- a/src/plugins/tracker/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker/rygel-tracker-category-all-container.vala
@@ -55,13 +55,15 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
io_error.message);
}
- try {
- var uri = Filename.to_uri (item_factory.upload_dir, null);
- this.add_uri (uri);
- } catch (ConvertError error) {
- warning (_("Failed to construct URI for folder '%s': %s"),
- item_factory.upload_dir,
- error.message);
+ if (item_factory.upload_dir != null) {
+ try {
+ var uri = Filename.to_uri (item_factory.upload_dir, null);
+ this.add_uri (uri);
+ } catch (ConvertError error) {
+ warning (_("Failed to construct URI for folder '%s': %s"),
+ item_factory.upload_dir,
+ error.message);
+ }
}
try {
diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala
b/src/plugins/tracker/rygel-tracker-item-factory.vala
index 7673b7b..5c30743 100644
--- a/src/plugins/tracker/rygel-tracker-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-item-factory.vala
@@ -52,7 +52,7 @@ public abstract class Rygel.Tracker.ItemFactory {
public string category;
public string category_iri;
public string upnp_class;
- public string upload_dir;
+ public string? upload_dir;
public ArrayList<string> properties;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]