From f63c3fe13c6ed822689e8bc57ea0660596fc1e04 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 3 May 2019 19:02:18 +0700 Subject: [PATCH] Experiment with artwork thumbnail support --- build-data/BuildArtwork.groovy | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build-data/BuildArtwork.groovy b/build-data/BuildArtwork.groovy index 7accf61a..3ae1a494 100755 --- a/build-data/BuildArtwork.groovy +++ b/build-data/BuildArtwork.groovy @@ -23,9 +23,7 @@ File getThumbnailPath(db, id) { void createThumbnail(original, thumb) { - if (!thumb.dir.exists()) { - thumb.dir.mkdirs() - } + thumb.dir.mkdirs() execute '/usr/local/bin/convert', original, '-strip', '-thumbnail', '48x48>', 'PNG8:' + thumb } @@ -53,7 +51,15 @@ void build(ids, section, db, query) { return } - def artwork = db.getArtwork id, query, Locale.ENGLISH + def artwork = retry(2, 60000) { + try { + return db.getArtwork(id, query, Locale.ENGLISH) + } catch (FileNotFoundException e) { + log.warning "[ARTWORK NOT FOUND] $e" + return null + } + } + if (!artwork) { original.createNewFile() ls original @@ -66,7 +72,7 @@ void build(ids, section, db, query) { log.fine "Fetch $a" return a.url.saveAs(original) } catch (FileNotFoundException e) { - log.warning "[FILE NOT FOUND] $e" + log.warning "[IMAGE NOT FOUND] $e" return null } }