diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/db-artwork-writer.c | 4 | ||||
-rw-r--r-- | src/itdb_photoalbum.c | 17 | ||||
-rw-r--r-- | src/itdb_private.h | 2 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c index 21b6a91..50e65b3 100644 --- a/src/db-artwork-writer.c +++ b/src/db-artwork-writer.c @@ -1086,8 +1086,8 @@ ipod_write_photo_db (Itdb_PhotoDB *photodb) g_free (filename); return -1; } - id_max = itdb_get_free_photo_id( photodb ); - bytes_written = write_mhfd (&db, buf, id_max); + id_max = itdb_get_max_photo_id( photodb ); + bytes_written = write_mhfd (&db, buf, id_max+1); /* Refcount of the shared buffer should drop to 0 and this should * sync buffered data to disk diff --git a/src/itdb_photoalbum.c b/src/itdb_photoalbum.c index 994875e..b55c4d0 100644 --- a/src/itdb_photoalbum.c +++ b/src/itdb_photoalbum.c @@ -309,19 +309,26 @@ void itdb_photodb_free (Itdb_PhotoDB *photodb) -G_GNUC_INTERNAL gint itdb_get_free_photo_id ( Itdb_PhotoDB *db ) +G_GNUC_INTERNAL gint itdb_get_max_photo_id ( Itdb_PhotoDB *db ) { - gint photo_id = 0; + gint max_seen_id = 0; GList *it; for (it = db->photos; it != NULL; it = it->next) { Itdb_Artwork *artwork; artwork = (Itdb_Artwork *)it->data; - if( artwork->id > photo_id ) - photo_id = artwork->id; + if( artwork->id > max_seen_id ) + max_seen_id = artwork->id; } - return photo_id + 1; + for (it = db->photoalbums; it != NULL; it = it->next) { + Itdb_PhotoAlbum *album; + album = (Itdb_PhotoAlbum *)it->data; + if ( album->album_id > max_seen_id ) + max_seen_id = album->album_id; + + } + return max_seen_id; } static void itdb_photodb_photoalbum_free (Itdb_PhotoAlbum *album) diff --git a/src/itdb_private.h b/src/itdb_private.h index 7e9e410..2417423 100644 --- a/src/itdb_private.h +++ b/src/itdb_private.h @@ -146,7 +146,7 @@ G_GNUC_INTERNAL void itdb_splr_free (Itdb_SPLRule *splr); G_GNUC_INTERNAL const gchar *itdb_photodb_get_mountpoint (Itdb_PhotoDB *photodb); G_GNUC_INTERNAL gchar *db_get_mountpoint (Itdb_DB *db); G_GNUC_INTERNAL Itdb_Device *db_get_device(Itdb_DB *db); -G_GNUC_INTERNAL gint itdb_get_free_photo_id ( Itdb_PhotoDB *db ); +G_GNUC_INTERNAL gint itdb_get_max_photo_id ( Itdb_PhotoDB *db ); G_GNUC_INTERNAL Itdb_iTunesDB *db_get_itunesdb (Itdb_DB *db); G_GNUC_INTERNAL Itdb_PhotoDB *db_get_photodb (Itdb_DB *db); G_GNUC_INTERNAL gint itdb_thumb_get_byteorder (ItdbThumbFormat format); |