commit e84adfd69c224f5a04bc672e1fe7f1e2b20babd1
Author: Nikias Bassen <[email protected]>
Date:   Sat Oct 10 13:30:50 2009 +0200

    reorder code in write_file_internal to make it more extensible

 src/itdb_itunesdb.c |   90 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 57 insertions(+), 33 deletions(-)
---
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 9d9c3fe..dc7d52b 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -5382,42 +5382,66 @@ static gboolean itdb_write_file_internal (Itdb_iTunesDB 
*itdb,
     }
 #endif
 
-    mk_mhbd (fexp, 4);   /* four mhsds */
-    /* write tracklist */
-    if (write_mhsd_tracks (fexp))
-    {   /* write special podcast version mhsd */
-       if (write_mhsd_playlists (fexp, 3))
-       {   /* write standard playlist mhsd */
-           if (write_mhsd_playlists (fexp, 2))
-           {
-               if (write_mhsd_albums (fexp)) {
-                   fix_header (cts, mhbd_seek);
-                   if (compressed_filename) {
-                       /* If we were asked to write a compressed file, starts 
by writing
-                        * an uncompressed copy of the iTunesDB
-                        */
-                       itdb_device_write_checksum (itdb->device,
-                                                   (unsigned char 
*)fexp->wcontents->contents,
-                                                   fexp->wcontents->pos,
-                                                   NULL);
-                       wcontents_write (cts);
-                       if (!itdb_zlib_check_compress_fexp (fexp)) {
-                           goto err;
-                       }
-                       g_free (cts->filename);
-                       cts->filename = g_strdup (compressed_filename);
-                   }
-
-                   /* Set checksum (ipods require it starting from Classic and 
Nano Video) */
-                   itdb_device_write_checksum (itdb->device,
-                                               (unsigned char 
*)fexp->wcontents->contents,
-                                               fexp->wcontents->pos,
-                                               &fexp->error);
-               }
-           }
+    mk_mhbd (fexp, 4);  /* four mhsds */
+
+    /* write albums (mhsd type 4) */
+    if (!write_mhsd_albums (fexp)) {
+       g_set_error (&fexp->error,
+                    ITDB_FILE_ERROR,
+                    ITDB_FILE_ERROR_ITDB_CORRUPT,
+                    _("Error writing list of albums (mhsd type 4)"));
+       goto err;
+    }
+
+    /* write tracklist (mhsd type 1) */
+    if (!fexp->error && !write_mhsd_tracks (fexp)) {
+       g_set_error (&fexp->error,
+                    ITDB_FILE_ERROR,
+                    ITDB_FILE_ERROR_ITDB_CORRUPT,
+                    _("Error writing list of tracks (mhsd type 1)"));
+       goto err;
+    }
+
+    /* write special podcast version mhsd (mhsd type 3) */
+    if (!fexp->error && !write_mhsd_playlists (fexp, 3)) {
+        g_set_error (&fexp->error,
+                    ITDB_FILE_ERROR,
+                    ITDB_FILE_ERROR_ITDB_CORRUPT,
+                    _("Error writing special podcast playlists (mhsd type 
3)"));
+       goto err;
+    }
+    /* write standard playlist mhsd (mhsd type 2) */
+    if (!fexp->error && !write_mhsd_playlists (fexp, 2)) {
+        g_set_error (&fexp->error,
+                    ITDB_FILE_ERROR,
+                    ITDB_FILE_ERROR_ITDB_CORRUPT,
+                    _("Error writing standard playlists (mhsd type 2)"));
+       goto err;
+    }
+
+    fix_header (cts, mhbd_seek);
+    if (compressed_filename) {
+       /* If we were asked to write a compressed file, starts by writing
+        * an uncompressed copy of the iTunesDB
+        */
+       itdb_device_write_checksum (itdb->device,
+                                   (unsigned char *)fexp->wcontents->contents,
+                                   fexp->wcontents->pos,
+                                   NULL);
+       wcontents_write (cts);
+       if (!itdb_zlib_check_compress_fexp (fexp)) {
+           goto err;
        }
+       g_free (cts->filename);
+       cts->filename = g_strdup (compressed_filename);
     }
 
+    /* Set checksum (ipods require it starting from Classic and Nano Video) */
+    itdb_device_write_checksum (itdb->device,
+                               (unsigned char *)fexp->wcontents->contents,
+                               fexp->wcontents->pos,
+                               &fexp->error);
+
     if (!fexp->error)
     {
        if (!wcontents_write (cts))

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to