Example #1
0
        private void Reset()
        {
            lock (queue) {
                if (user_job != null)
                {
                    user_job.CancelRequested -= OnCancelRequested;
                    user_job.Finished        -= OnFinished;
                    user_job.Finish();
                    user_job = null;
                }

                if (transcoder != null)
                {
                    transcoder.Finish();
                    transcoder = null;
                }

                foreach (TranscodeContext context in queue)
                {
                    context.CancelledHandler();
                }

                if (transcoding)
                {
                    current_context.CancelledHandler();
                    transcoding = false;
                }

                queue.Clear();
            }
        }
Example #2
0
        private void OnFinished(object o, EventArgs args)
        {
            job.Finish();

            if (cancelled)
            {
                return;
            }

            //Hyena.Log.DebugFormat ("Have {0} items before delete", ServiceManager.DbConnection.Query<int>("select count(*) from coretracks where primarysourceid=?", psource.DbId));

            // Delete tracks that are under the BaseDirectory and that weren't rescanned just now
            string condition = String.Format(
                "WHERE PrimarySourceID = ? AND Uri LIKE '{0}%' AND LastSyncedStamp IS NOT NULL AND LastSyncedStamp < ?",
                new SafeUri(psource.BaseDirectoryWithSeparator).AbsoluteUri
                );

            ServiceManager.DbConnection.Execute(String.Format(@"BEGIN;
                    DELETE FROM CorePlaylistEntries WHERE TrackID IN (SELECT TrackID FROM CoreTracks {0});
                    DELETE FROM CoreSmartPlaylistEntries WHERE TrackID IN (SELECT TrackID FROM CoreTracks {0});
                    DELETE FROM CoreTracks {0}; COMMIT",
                                                              condition),
                                                psource.DbId, scan_started,
                                                psource.DbId, scan_started,
                                                psource.DbId, scan_started
                                                );

            // TODO prune artists/albums
            psource.Reload();
            psource.NotifyTracksChanged();
            //Hyena.Log.DebugFormat ("Have {0} items after delete", ServiceManager.DbConnection.Query<int>("select count(*) from coretracks where primarysourceid=?", psource.DbId));
        }
Example #3
0
        private void OnFinished(object o, EventArgs args)
        {
            job.Finish();

            if (cancelled || remove_confirmation == null)
            {
                return;
            }

            //Hyena.Log.DebugFormat ("Have {0} items before delete", ServiceManager.DbConnection.Query<int>("select count(*) from coretracks where primarysourceid=?", psource.DbId));

            // Delete tracks that are under the BaseDirectory and that weren't rescanned just now
            string condition = String.Format(
                @"WHERE PrimarySourceID = ? AND {0} LIKE ? ESCAPE '\' AND {1} IS NOT NULL AND {1} < ?",
                Banshee.Query.BansheeQuery.UriField.Column, "CoreTracks.LastSyncedStamp"
                );
            string uri = Hyena.StringUtil.EscapeLike(new SafeUri(psource.BaseDirectoryWithSeparator).AbsoluteUri) + "%";

            int remove_count = ServiceManager.DbConnection.Query <int> (
                String.Format(@"SELECT COUNT('x') FROM CoreTracks {0}", condition),
                psource.DbId, uri, scan_started);

            if (remove_count > MAX_NOWARN_TRACKS_REMOVAL)
            {
                if (!remove_confirmation(remove_count))
                {
                    Refresh();
                    return;
                }
            }

            if (remove_count > 0)
            {
                ServiceManager.DbConnection.Execute(String.Format(@"BEGIN;
                        DELETE FROM CorePlaylistEntries WHERE TrackID IN (SELECT TrackID FROM CoreTracks {0});
                        DELETE FROM CoreSmartPlaylistEntries WHERE TrackID IN (SELECT TrackID FROM CoreTracks {0});
                        DELETE FROM CoreTracks {0}; COMMIT",
                                                                  condition),
                                                    psource.DbId, uri, scan_started,
                                                    psource.DbId, uri, scan_started,
                                                    psource.DbId, uri, scan_started
                                                    );
            }

            // TODO prune artists/albums
            Refresh();
            //Hyena.Log.DebugFormat ("Have {0} items after delete", ServiceManager.DbConnection.Query<int>("select count(*) from coretracks where primarysourceid=?", psource.DbId));
        }
        /// <summary>
        /// Sets the tracks of this source. All tracks previously contained in this source are purged.
        /// </summary>
        /// <param name="tracks">
        /// A <see cref="List<DatabaseTrackInfo>"/> -- the list of tracks to be contained in the source
        /// </param>
        public void SetStations(List <DatabaseTrackInfo> tracks)
        {
            this.PurgeTracks();
            BatchUserJob add_track_job = AddTrackJob;

            add_track_job.Total            = tracks.Count;
            add_track_job.CancelRequested += OnAddTrackJobCancelRequested;
            this.PauseSorting();
            foreach (DatabaseTrackInfo track in tracks)
            {
                AddStation(track);
                this.IncrementAddedTracks();
                if (add_track_job_cancelled)
                {
                    add_track_job_cancelled = false;
                    Hyena.Log.Debug("[LiveRadioPluginSource]<AddStations> job cancelled");
                    add_track_job.Completed = add_track_job.Total;
                    return;
                }
            }
            add_track_job.Finish();
            this.ResumeSorting();
        }