banshee r2978 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Hyena src/Core/Hyena/Hyena.Data src/Core/Hyena/Hyena.Data.Sqlite
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r2978 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Hyena src/Core/Hyena/Hyena.Data src/Core/Hyena/Hyena.Data.Sqlite
- Date: Thu, 17 Jan 2008 06:13:52 +0000 (GMT)
Author: scottp
Date: Thu Jan 17 06:13:51 2008
New Revision: 2978
URL: http://svn.gnome.org/viewvc/banshee?rev=2978&view=rev
Log:
* src/Core/Hyena/Hyena.Data/ModelCache.cs,
src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs: These
changes are already obsolete by Gabriel's work.
* src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs:
Fix for correctly translating Uris from the db.
* src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModelCache.cs:
Made constant strings even more constant.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModelCache.cs
trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs
trunk/banshee/src/Core/Hyena/Hyena.Data/ModelCache.cs
trunk/banshee/src/Core/Hyena/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/LibraryTrackInfo.cs Thu Jan 17 06:13:51 2008
@@ -119,11 +119,52 @@
[DatabaseColumn]
private string MusicBrainzID;
+ private string uri_field;
[DatabaseColumn("Uri")]
- private string uri;
+ private string uri {
+ get {
+ return
+ uri_field ??
+ (Uri == null
+ ? null
+ : (Paths.MakePathRelativeToLibrary (Uri.AbsolutePath) ?? Uri.AbsoluteUri)
+ );
+ }
+ set {
+ uri_field = value;
+ if (uri_type_field.HasValue) {
+ SetUpUri();
+ }
+ }
+ }
+ private int? uri_type_field;
[DatabaseColumn("UriType")]
- private int uri_type;
+ private int uri_type {
+ get {
+ return uri_type_field.HasValue
+ ? uri_type_field.Value
+ : (Uri == null
+ ? (int)UriType.RelativePath
+ : (Paths.MakePathRelativeToLibrary (Uri.AbsolutePath) != null
+ ? (int)UriType.RelativePath
+ : (int)UriType.AbsoluteUri));
+ }
+ set {
+ uri_type_field = value;
+ if (uri_field != null) {
+ SetUpUri();
+ }
+ }
+ }
+
+ private void SetUpUri()
+ {
+ if (uri_type_field.Value == (int)UriType.RelativePath) {
+ uri_field = System.IO.Path.Combine(Paths.LibraryLocation, uri_field);
+ }
+ Uri = new SafeUri(uri_field);
+ }
[DatabaseColumn]
public override string MimeType {
@@ -202,20 +243,6 @@
get { return DateTimeUtil.FromDateTime(DateAdded); }
set { DateAdded = DateTimeUtil.ToDateTime(value); }
}
-
- private bool set_up;
- public void SetUp()
- {
- if(set_up) {
- return;
- }
- set_up = true;
-
- if (uri_type == (int)UriType.RelativePath) {
- uri = System.IO.Path.Combine(Paths.LibraryLocation, uri);
- }
- Uri = new SafeUri(uri);
- }
private static BansheeDbCommand check_command = new BansheeDbCommand (
"SELECT COUNT(*) FROM CoreTracks WHERE Uri = ? OR Uri = ?", 2);
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModelCache.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModelCache.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDatabaseModelCache.cs Thu Jan 17 06:13:51 2008
@@ -40,15 +40,13 @@
public BansheeDatabaseModelCache (HyenaSqliteConnection connection, string uuid, ICacheableDatabaseModel<T> model) : base (connection, uuid, model)
{
}
-
- private const string model_table = "CoreCacheModels";
+
protected override string CacheModelsTableName {
- get { return model_table; }
+ get { return "CoreCacheModels"; }
}
- private const string cache_table = "CoreCache";
protected override string CacheTableName {
- get { return cache_table; }
+ get { return "CoreCache"; }
}
}
}
Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/DatabaseModelCache.cs Thu Jan 17 06:13:51 2008
@@ -120,9 +120,9 @@
int i = offset;
T item;
while (reader.Read ()) {
- if (!Cache.ContainsKey (i)) {
+ if (!Contains (i)) {
item = db_model.GetItemFromReader (reader, i);
- Cache.Add (i, item);
+ Add (i, item);
}
i++;
}
Modified: trunk/banshee/src/Core/Hyena/Hyena.Data/ModelCache.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data/ModelCache.cs (original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data/ModelCache.cs Thu Jan 17 06:13:51 2008
@@ -41,26 +41,27 @@
this.model = model;
}
- protected virtual Dictionary<int, T> Cache {
- get { return cache; }
- }
-
public virtual T GetValue (int index)
{
- if (Cache.ContainsKey (index))
- return Cache[index];
+ if (cache.ContainsKey (index))
+ return cache[index];
FetchSet (index, model.FetchCount);
- if (Cache.ContainsKey (index))
- return Cache[index];
+ if (cache.ContainsKey (index))
+ return cache[index];
return default (T);
}
- protected virtual void Add(int key, T value)
+ protected virtual bool Contains (int key)
+ {
+ return cache.ContainsKey (key);
+ }
+
+ protected virtual void Add (int key, T value)
{
- Cache.Add(key, value);
+ cache.Add (key, value);
}
// Responsible for fetching a set of items and placing them in the cache
@@ -76,7 +77,7 @@
protected void InvalidateManagedCache ()
{
- Cache.Clear ();
+ cache.Clear ();
}
}
}
Modified: trunk/banshee/src/Core/Hyena/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Hyena/Makefile.am (original)
+++ trunk/banshee/src/Core/Hyena/Makefile.am Thu Jan 17 06:13:51 2008
@@ -20,14 +20,13 @@
Hyena.Data.Query/QueryToken.cs \
Hyena.Data.Query/UserQueryParser.cs \
Hyena.Data.Query/XmlQueryParser.cs \
- Hyena.Data.Sqlite/ICacheableDatabaseModel.cs \
- Hyena.Data.Sqlite/DatabaseModelCache.cs \
Hyena.Data.Sqlite/DatabaseColumn.cs \
Hyena.Data.Sqlite/DatabaseColumnAttribute.cs \
Hyena.Data.Sqlite/DatabaseModel.cs \
+ Hyena.Data.Sqlite/DatabaseModelCache.cs \
Hyena.Data.Sqlite/HyenaSqliteCommand.cs \
Hyena.Data.Sqlite/HyenaSqliteConnection.cs \
- Hyena.Data/ModelCache.cs \
+ Hyena.Data.Sqlite/ICacheableDatabaseModel.cs \
Hyena.Data/ColumnDescription.cs \
Hyena.Data/ICacheableModel.cs \
Hyena.Data/ICareAboutView.cs \
@@ -36,6 +35,7 @@
Hyena.Data/IPropertyStoreExpose.cs \
Hyena.Data/ISortable.cs \
Hyena.Data/ISortableColumn.cs \
+ Hyena.Data/ModelCache.cs \
Hyena.Data/ModelSelection.cs \
Hyena.Data/PropertyStore.cs \
Hyena.Data/SortType.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]