Exemplo n.º 1
0
        public void Save(bool notify, params QueryField [] fields_changed)
        {
            // If either the artist or album changed,
            if (ArtistId == 0 || AlbumId == 0 || artist_changed == true || album_changed == true)
            {
                DatabaseArtistInfo artist = Artist;
                ArtistId = artist.DbId;

                DatabaseAlbumInfo album = Album;
                AlbumId = album.DbId;

                // TODO get rid of unused artists/albums
            }

            // If PlayCountField is not transient we still want to update the file only if it's from the music library
            var transient = transient_fields;

            if (!transient.Contains(BansheeQuery.PlayCountField) &&
                !ServiceManager.SourceManager.MusicLibrary.Equals(PrimarySource))
            {
                transient = new HashSet <QueryField> (transient_fields);
                transient.Add(BansheeQuery.PlayCountField);
            }

            if (fields_changed.Length == 0 || !transient.IsSupersetOf(fields_changed))
            {
                DateUpdated = DateTime.Now;
            }

            bool is_new = (TrackId == 0);

            if (is_new)
            {
                LastSyncedStamp = DateAdded = DateUpdated = DateTime.Now;
            }

            ProviderSave();

            if (notify && PrimarySource != null)
            {
                if (is_new)
                {
                    PrimarySource.NotifyTracksAdded();
                }
                else
                {
                    PrimarySource.NotifyTracksChanged(fields_changed);
                }
            }
        }
Exemplo n.º 2
0
        public void Save(bool notify, params QueryField [] fields_changed)
        {
            // If either the artist or album changed,
            if (ArtistId == 0 || AlbumId == 0 || artist_changed == true || album_changed == true)
            {
                DatabaseArtistInfo artist = Artist;
                ArtistId = artist.DbId;

                DatabaseAlbumInfo album = Album;
                AlbumId = album.DbId;

                // TODO get rid of unused artists/albums
            }

            if (fields_changed.Length == 0 || !transient_fields.IsSupersetOf(fields_changed))
            {
                DateUpdated = DateTime.Now;
            }

            bool is_new = (TrackId == 0);

            if (is_new)
            {
                DateAdded = DateUpdated = DateTime.Now;
            }

            ProviderSave();

            if (notify && PrimarySource != null)
            {
                if (is_new)
                {
                    PrimarySource.NotifyTracksAdded();
                }
                else
                {
                    PrimarySource.NotifyTracksChanged(fields_changed);
                }
            }
        }