From 6ebd26ecfd2a83557f176fb5dd559ed389775f14 Mon Sep 17 00:00:00 2001 From: theguardian Date: Wed, 23 Oct 2013 17:31:21 -0700 Subject: [PATCH 1/4] Fixed minor issue where manual 'have' tracks would be unmatched if a local file was deleted. --- headphones/librarysync.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index a9f76d11..cda014e6 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -61,7 +61,6 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal encoded_track_string = track['Location'].encode(headphones.SYS_ENCODING) if not os.path.isfile(encoded_track_string): myDB.action('DELETE FROM have WHERE Location=?', [track['Location']]) - myDB.action('UPDATE have SET Matched=NULL WHERE Matched=?', [track['Matched']]) logger.info('File %s removed from Headphones, as it is no longer on disk' % encoded_track_string.decode(headphones.SYS_ENCODING, 'replace')) ###############myDB.action('DELETE from have') From 4c8f11555e6ef7369f9771cf2c59c46e33e07e14 Mon Sep 17 00:00:00 2001 From: theguardian Date: Wed, 23 Oct 2013 21:34:12 -0700 Subject: [PATCH 2/4] Added database indices on allalbums/alltracks tables. Active artist update FLIES throughout the process when starting from scratch. --- headphones/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/headphones/__init__.py b/headphones/__init__.py index d99bf819..2dd83f7b 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -953,6 +953,9 @@ def dbcheck(): c.execute('CREATE TABLE IF NOT EXISTS releases (ReleaseID TEXT, ReleaseGroupID TEXT, UNIQUE(ReleaseID, ReleaseGroupID))') c.execute('CREATE INDEX IF NOT EXISTS tracks_albumid ON tracks(AlbumID ASC)') c.execute('CREATE INDEX IF NOT EXISTS album_artistid_reldate ON albums(ArtistID ASC, ReleaseDate DESC)') + c.execute('CREATE INDEX IF NOT EXISTS alltracks_relid ON alltracks(ReleaseID ASC, TrackID ASC)') + c.execute('CREATE INDEX IF NOT EXISTS allalbums_relid ON allalbums(ReleaseID ASC)') + c.execute('CREATE INDEX IF NOT EXISTS have_location ON have(Location ASC)') try: c.execute('SELECT IncludeExtras from artists') From af0e570b4411fcbda810f6ef9867d1817a18a0d3 Mon Sep 17 00:00:00 2001 From: theguardian Date: Thu, 24 Oct 2013 09:20:18 -0700 Subject: [PATCH 3/4] Fixed minor bug where track numbers were out of order on album page (due to new index) --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index bdc33b73..ed79a809 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -108,7 +108,7 @@ class WebInterface(object): def albumPage(self, AlbumID): myDB = db.DBConnection() album = myDB.action('SELECT * from albums WHERE AlbumID=?', [AlbumID]).fetchone() - tracks = myDB.select('SELECT * from tracks WHERE AlbumID=?', [AlbumID]) + tracks = myDB.select('SELECT * from tracks WHERE AlbumID=? ORDER BY CAST(TrackNumber AS INTEGER)', [AlbumID]) description = myDB.action('SELECT * from descriptions WHERE ReleaseGroupID=?', [AlbumID]).fetchone() title = album['ArtistName'] + ' - ' + album['AlbumTitle'] return serve_template(templatename="album.html", title=title, album=album, tracks=tracks, description=description) From 17fb7938331e14c2e73dbf73382265ccf71f295a Mon Sep 17 00:00:00 2001 From: theguardian Date: Thu, 24 Oct 2013 14:48:04 -0700 Subject: [PATCH 4/4] Added indices on tracks/alltracks/have tables to speed up library sync & improve overall speed of browsing headphones. --- headphones/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/headphones/__init__.py b/headphones/__init__.py index 2dd83f7b..ab0674c3 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -953,9 +953,17 @@ def dbcheck(): c.execute('CREATE TABLE IF NOT EXISTS releases (ReleaseID TEXT, ReleaseGroupID TEXT, UNIQUE(ReleaseID, ReleaseGroupID))') c.execute('CREATE INDEX IF NOT EXISTS tracks_albumid ON tracks(AlbumID ASC)') c.execute('CREATE INDEX IF NOT EXISTS album_artistid_reldate ON albums(ArtistID ASC, ReleaseDate DESC)') + #Below creates indices to speed up Active Artist updating c.execute('CREATE INDEX IF NOT EXISTS alltracks_relid ON alltracks(ReleaseID ASC, TrackID ASC)') c.execute('CREATE INDEX IF NOT EXISTS allalbums_relid ON allalbums(ReleaseID ASC)') c.execute('CREATE INDEX IF NOT EXISTS have_location ON have(Location ASC)') + #Below creates indices to speed up library scanning & matching + c.execute('CREATE INDEX IF NOT EXISTS have_Metadata ON have(ArtistName ASC, AlbumTitle ASC, TrackTitle ASC)') + c.execute('CREATE INDEX IF NOT EXISTS have_CleanName ON have(CleanName ASC)') + c.execute('CREATE INDEX IF NOT EXISTS tracks_Metadata ON tracks(ArtistName ASC, AlbumTitle ASC, TrackTitle ASC)') + c.execute('CREATE INDEX IF NOT EXISTS tracks_CleanName ON tracks(CleanName ASC)') + c.execute('CREATE INDEX IF NOT EXISTS alltracks_Metadata ON alltracks(ArtistName ASC, AlbumTitle ASC, TrackTitle ASC)') + c.execute('CREATE INDEX IF NOT EXISTS alltracks_CleanName ON alltracks(CleanName ASC)') try: c.execute('SELECT IncludeExtras from artists')