From a4bd22fd5ca2d98a60e536374b6772513f5f9856 Mon Sep 17 00:00:00 2001
From: Nikias Bassen <nikias@gmx.li>
Date: Tue, 25 Aug 2009 14:44:29 +0200
Subject: [PATCH 12/14] Write Artwork AFTER copying the iTunesDB file to the device.

---
 src/itdb_itunesdb.c |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 5575c09..4a479a1 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -6176,22 +6176,6 @@ gboolean itdb_write_file (Itdb_iTunesDB *itdb, const gchar *filename,
 
     prepare_itdb_for_write (fexp);
 
-#if HAVE_GDKPIXBUF
-    /* only write ArtworkDB if we deal with an iPod
-       FIXME: figure out a way to store the artwork data when storing
-       to local directories. At the moment it's the application's task
-       to handle this. */
-    /* The ArtworkDB must be written after the call to
-     * prepare_itdb_for_write since it needs Itdb_Track::id to be set
-     * to its final value to write properly on nano video/ipod classics
-     */
-    if (itdb_device_supports_artwork (itdb->device)) {
-	printf("writing artwork\n");
-		ipod_write_artwork_db (itdb);
-	printf("done\n");
-    }
-#endif
-
     if (fexp->itdb->version >= 0x28) {
 	mk_mhbd (fexp, 7);  /* seven mhsds */
 	make_albums = TRUE;
@@ -6565,6 +6549,21 @@ gboolean itdb_write (Itdb_iTunesDB *itdb, GError **error)
 	    }
 	}
 
+#if HAVE_GDKPIXBUF
+    /* only write ArtworkDB if we deal with an iPod
+       FIXME: figure out a way to store the artwork data when storing
+       to local directories. At the moment it's the application's task
+       to handle this. */
+    /* The ArtworkDB must be written after the call to
+     * prepare_itdb_for_write since it needs Itdb_Track::id to be set
+     * to its final value to write properly on nano video/ipod classics
+     */
+    if (itdb_device_supports_artwork (itdb->device)) {
+	printf("writing artwork\n");
+		ipod_write_artwork_db (itdb);
+	printf("done\n");
+    }
+#endif
 
 	/* Write SysInfo file if it has changed */
 	if (itdb->device->sysinfo_changed)
-- 
1.6.4.4

