From 2f8abf7dca4949b2efde3464c3a1e96d42f0aa49 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 20 Aug 2012 22:37:37 +0530 Subject: [PATCH] Add error checking to importer, so we don't mark an artist as being updated if not all albums were added/refreshed --- headphones/importer.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index 571360e9..50c7531e 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -103,6 +103,9 @@ def addArtisttoDB(artistid, extrasonly=False): logger.warn('Cannot import Various Artists.') return + # We'll use this to see if we should update the 'LastUpdated' time stamp + errors = False + myDB = db.DBConnection() # Delete from blacklist if it's on there @@ -171,6 +174,7 @@ def addArtisttoDB(artistid, extrasonly=False): continue if not releaselist: + errors = True continue # This will be used later to build a hybrid release @@ -186,10 +190,12 @@ def addArtisttoDB(artistid, extrasonly=False): try: releasedict = mb.getRelease(releaseid, include_artist_info=False) except Exception, e: + errors = True logger.info('Unable to get release information for %s: %s' % (release['id'], e)) continue if not releasedict: + errors = True continue controlValueDict = {"ReleaseID": release['id']} @@ -412,14 +418,18 @@ def addArtisttoDB(artistid, extrasonly=False): "TotalTracks": totaltracks, "HaveTracks": havetracks} - newValueDict['LastUpdated'] = helpers.now() + if not errors: + newValueDict['LastUpdated'] = helpers.now() myDB.upsert("artists", newValueDict, controlValueDict) logger.info(u"Seeing if we need album art for: " + artist['artist_name']) cache.getThumb(ArtistID=artistid) - logger.info(u"Updating complete for: " + artist['artist_name']) + if errors: + logger.info("Finished updating artist: " + artist['artist_name'] + " but with errors, so not marking it as updated in the database") + else: + logger.info(u"Updating complete for: " + artist['artist_name']) def addReleaseById(rid):