banshee r3535 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs src/Libraries/Hyena/Hyena.Data
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3535 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Library src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs src/Libraries/Hyena/Hyena.Data
- Date: Tue, 25 Mar 2008 18:45:23 +0000 (GMT)
Author: gburt
Date: Tue Mar 25 18:45:22 2008
New Revision: 3535
URL: http://svn.gnome.org/viewvc/banshee?rev=3535&view=rev
Log:
2008-03-25 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs:
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs:
In FindOrCreate methods, cache the last result to avoid looking up an
artist and album for each track in an album.
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs:
Within the Save method make sure the artist and album are up to date and
in the database.
* src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs:
Album/artist creation now done in DatabaseTrackInfo.
* src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/TrackEditor.cs:
Re-enable editing of artist/albums.
* src/Libraries/Hyena/Hyena.Data/ArrayModelCache.cs: Forgot to put
threading fix in this when previously updated DictionaryModelCache.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/TrackEditor.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data/ArrayModelCache.cs
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs Tue Mar 25 18:45:22 2008
@@ -58,26 +58,34 @@
ArtistName
}
+ private static int last_artist_id;
+ private static string last_title;
+ private static DatabaseAlbumInfo last_album;
public static DatabaseAlbumInfo FindOrCreate (DatabaseArtistInfo artist, string title)
{
- DatabaseAlbumInfo album;
+ if (title == last_title && artist.DbId == last_artist_id) {
+ return last_album;
+ }
if (title == null || title.Trim () == String.Empty)
title = Catalog.GetString ("Unknown Album");
using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artist.DbId, title)) {
if (reader.Read ()) {
- album = new DatabaseAlbumInfo (reader);
- album.ArtistName = artist.Name;
+ last_album = new DatabaseAlbumInfo (reader);
+ last_album.ArtistName = artist.Name;
} else {
- album = new DatabaseAlbumInfo ();
- album.Title = title;
- album.ArtistId = artist.DbId;
- album.ArtistName = artist.Name;
- album.Save ();
+ last_album = new DatabaseAlbumInfo ();
+ last_album.Title = title;
+ last_album.ArtistId = artist.DbId;
+ last_album.ArtistName = artist.Name;
+ last_album.Save ();
}
}
- return album;
+
+ last_title = title;
+ last_artist_id = artist.DbId;
+ return last_album;
}
public DatabaseAlbumInfo () : base (null)
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistInfo.cs Tue Mar 25 18:45:22 2008
@@ -57,23 +57,29 @@
Name
}
+ private static string last_artist_name = null;
+ private static DatabaseArtistInfo last_artist = null;
public static DatabaseArtistInfo FindOrCreate (string artistName)
{
- DatabaseArtistInfo artist;
+ if (artistName == last_artist_name) {
+ return last_artist;
+ }
if (artistName == null || artistName.Trim () == String.Empty)
artistName = Catalog.GetString ("Unknown Artist");
using (IDataReader reader = ServiceManager.DbConnection.Query (select_command, artistName)) {
if (reader.Read ()) {
- artist = new DatabaseArtistInfo (reader);
+ last_artist = new DatabaseArtistInfo (reader);
} else {
- artist = new DatabaseArtistInfo ();
- artist.Name = artistName;
- artist.Save ();
+ last_artist = new DatabaseArtistInfo ();
+ last_artist.Name = artistName;
+ last_artist.Save ();
}
}
- return artist;
+
+ last_artist_name = artistName;
+ return last_artist;
}
public DatabaseArtistInfo () : base (null)
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs Tue Mar 25 18:45:22 2008
@@ -51,6 +51,8 @@
{
public class DatabaseTrackInfo : TrackInfo, ICacheableItem
{
+ private bool? artist_changed = null, album_changed = null;
+
private static BansheeModelProvider<DatabaseTrackInfo> provider = new BansheeModelProvider<DatabaseTrackInfo> (
ServiceManager.DbConnection, "CoreTracks"
);
@@ -99,15 +101,21 @@
public void Save (bool notify)
{
+ // If either the artist or album changed,
+ if (ArtistId == 0 || AlbumId == 0 || artist_changed == true || album_changed == true) {
+ DatabaseArtistInfo artist = DatabaseArtistInfo.FindOrCreate (ArtistName);
+ ArtistId = artist.DbId;
+
+ DatabaseAlbumInfo album = DatabaseAlbumInfo.FindOrCreate (artist, AlbumTitle);
+ AlbumId = album.DbId;
+
+ // TODO get rid of unused artists/albums
+ }
+
DateUpdated = DateTime.Now;
bool is_new = TrackId == 0;
Provider.Save (this);
- // Pattern for saving artist / album:
- // 1) if not dirty, ignore
- // 2) if dirty, look up, update our id if found, otherwise create
- // 3) delete unused ones
-
if (notify) {
if (is_new) {
PrimarySource.NotifyTracksAdded ();
@@ -152,13 +160,25 @@
[VirtualDatabaseColumn ("Name", "CoreArtists", "ArtistID", "ArtistID")]
public override string ArtistName {
get { return base.ArtistName; }
- set { base.ArtistName = value; }
+ set {
+ if (value == ArtistName)
+ return;
+
+ base.ArtistName = value;
+ artist_changed = artist_changed != null;
+ }
}
[VirtualDatabaseColumn ("Title", "CoreAlbums", "AlbumID", "AlbumID")]
public override string AlbumTitle {
get { return base.AlbumTitle; }
- set { base.AlbumTitle = value; }
+ set {
+ if (value == AlbumTitle)
+ return;
+
+ base.AlbumTitle = value;
+ album_changed = album_changed != null;
+ }
}
private int tag_set_id;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Library/LibraryImportManager.cs Tue Mar 25 18:45:22 2008
@@ -135,9 +135,6 @@
track.Uri = newpath;
}
- DatabaseArtistInfo artist = DatabaseArtistInfo.FindOrCreate (track.ArtistName);
- DatabaseAlbumInfo album = DatabaseAlbumInfo.FindOrCreate (artist, track.AlbumTitle);
-
track.DateAdded = DateTime.Now;
if ((track.MediaAttributes & TrackMediaAttributes.VideoStream) != 0) {
@@ -148,8 +145,6 @@
music_count++;
}
- track.ArtistId = artist.DbId;
- track.AlbumId = album.DbId;
track.Save (false);
ServiceManager.DbConnection.CommitTransaction ();
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/TrackEditor.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/TrackEditor.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Dialogs/TrackEditor.cs Tue Mar 25 18:45:22 2008
@@ -40,6 +40,8 @@
using Banshee.Widgets;
using Banshee.Configuration.Schema;
using Banshee.Collection;
+using Banshee.Sources;
+using Banshee.Collection.Database;
using Hyena.Gui;
@@ -202,10 +204,6 @@
EnterNextTitle.Clicked += OnEnterNextTitleClicked;
CoverButton.Clicked += OnCoverButtonClicked;
- // FIXME artist/album editing disabled for now in trunk
- Artist.Sensitive = false;
- Album.Sensitive = false;
-
Artist.Changed += OnValueEdited;
Album.Changed += OnValueEdited;
Title.Changed += OnValueEdited;
@@ -600,10 +598,13 @@
{
UpdateCurrent();
+ // TODO improve performance by not notifying each track's source until
+ // we've saved all tracks. Right now, if you edit two tracks in your library, the
+ // Library is reloaded twice.
foreach(EditorTrack track in TrackSet) {
SaveTrack(track, true);
}
-
+
EventHandler handler = Saved;
if(handler != null) {
handler(this, new EventArgs());
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data/ArrayModelCache.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data/ArrayModelCache.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data/ArrayModelCache.cs Tue Mar 25 18:45:22 2008
@@ -69,8 +69,10 @@
public override void Clear ()
{
- offset = -1;
- limit = 0;
+ lock (this) {
+ offset = -1;
+ limit = 0;
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]