[banshee] [InternetArchive] Handle missing file location attr
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [InternetArchive] Handle missing file location attr
- Date: Tue, 15 Jun 2010 19:34:24 +0000 (UTC)
commit 58ff5c16b1c95c23c561ae7e9552a340eaf2f86b
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Jun 15 12:32:15 2010 -0700
[InternetArchive] Handle missing file location attr
Usually each file entry in an item's JSON has a location attribute, but
apparently not all of them do (bgo#621687). If it's missing, fall back
to the file's hashtable key.
.../InternetArchive/Details.cs | 5 +++--
.../InternetArchive/DetailsFile.cs | 18 ++++++++++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
index e021b7f..6332a49 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
@@ -157,8 +157,9 @@ namespace InternetArchive
get {
string location_root = String.Format ("http://{0}{1}", details.Get<string> ("server"), details.Get<string> ("dir"));
var files = details["files"] as JsonObject;
- foreach (JsonObject file in files.Values) {
- yield return new DetailsFile (file, location_root);
+ foreach (string key in files.Keys) {
+ var file = files[key] as JsonObject;
+ yield return new DetailsFile (file, location_root, key);
}
}
}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs
index ae842ba..f604392 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs
@@ -40,15 +40,29 @@ namespace InternetArchive
{
JsonObject file;
string location_root;
+ string object_key;
- public DetailsFile (JsonObject file, string location_root)
+ public DetailsFile (JsonObject file, string location_root, string objectKey)
{
this.file = file;
this.location_root = location_root;
+ this.object_key = objectKey;
}
+ private string location;
public string Location {
- get { return location_root + file.Get<string> ("location"); }
+ get {
+ if (location == null) {
+ string loc = file.Get<string> ("location");
+ if (String.IsNullOrEmpty (loc)) {
+ loc = object_key ?? "";
+ }
+
+ location = location_root + loc;
+ }
+
+ return location;
+ }
}
public long Size {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]