diff -Naurb rhythmbox-0.9.8.old/plugins/ipod/rb-ipod-source.c rhythmbox-0.9.8/plugins/ipod/rb-ipod-source.c --- rhythmbox-0.9.8.old/plugins/ipod/rb-ipod-source.c 2007-02-12 07:17:00.000000000 -0600 +++ rhythmbox-0.9.8/plugins/ipod/rb-ipod-source.c 2007-03-25 17:58:56.000000000 -0500 @@ -86,7 +86,7 @@ static gchar* ipod_path_from_unix_path (const gchar *mount_point, const gchar *unix_path); #endif -static void itdb_schedule_save (Itdb_iTunesDB *db); +static void itdb_schedule_save (RBiPodSource *source); typedef struct { @@ -95,6 +95,7 @@ GHashTable *entry_map; GList *playlists; + gboolean needs_shuffle_db; guint load_idle_id; } RBiPodSourcePrivate; @@ -152,7 +153,7 @@ } g_free (mpl->name); mpl->name = g_strdup (name); - itdb_schedule_save (priv->ipod_db); + itdb_schedule_save (source); } else { g_warning ("iPod's master playlist is missing"); } @@ -580,11 +581,21 @@ { RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source); GnomeVFSVolume *volume; + const Itdb_IpodInfo *info; g_object_get (source, "volume", &volume, NULL); priv->ipod_mount_path = rb_ipod_get_mount_path (volume); priv->ipod_db = itdb_parse (priv->ipod_mount_path, NULL); + + info = itdb_device_get_ipod_info(priv->ipod_db->device); + if (info->ipod_generation == ITDB_IPOD_GENERATION_UNKNOWN || + info->ipod_model == ITDB_IPOD_MODEL_SHUFFLE) { + priv->needs_shuffle_db = TRUE; + } else { + priv->needs_shuffle_db = FALSE; + } + priv->entry_map = g_hash_table_new (g_direct_hash, g_direct_equal); if ((priv->ipod_db != NULL) && (priv->entry_map != NULL)) { Itdb_Playlist *mpl; @@ -911,8 +922,10 @@ } static void -itdb_schedule_save (Itdb_iTunesDB *db) +itdb_schedule_save (RBiPodSource *source) { + RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source); + /* FIXME: should probably be delayed a bit to avoid doing * it after each file when we are copying several files * consecutively @@ -920,7 +933,11 @@ * have a timeout firing every 5 seconds and saving the db if it's * dirty */ - itdb_write (db, NULL); + itdb_write (priv->ipod_db, NULL); + + if (priv->needs_shuffle_db) { + itdb_shuffle_write (priv->ipod_db, NULL); + } } #ifdef ENABLE_IPOD_WRITING @@ -972,7 +989,7 @@ song, -1); add_ipod_song_to_db (isource, db, song); - itdb_schedule_save (priv->ipod_db); + itdb_schedule_save (isource); } g_object_unref (db);