public void StopDownloadPackage(LocalPackageInfo package)
        {
            lock (syncLock)
            {
                // is really downloading?
                if (!downloads.Contains(package))
                {
                    return;
                }

                // update status
                if (package.DownloadStatus.IsDownloaded)
                {
                    package.DownloadStatus.Data.SegmentsBitmap = null;
                }
                // mark as "don't resume download"
                package.DownloadStatus.Data.IsDownloading = false;
                packageRegistry.UpdateDownloadStatus(package);

                // stop
                UpdateQueue(package, isInterested: false);
            }

            DownloadStatusChange?.Invoke(new DownloadStatusChange()
            {
                Package = package, HasStopped = true
            });
        }
Beispiel #2
0
 private void PackageDownloadManager_DownloadStatusChange(DownloadStatusChange obj)
 {
     // download started? make sure other peers knows we know this package
     if (obj.HasStarted)
     {
         PlanSendingClusterUpdate();
     }
 }
        public void StartDownloadPackage(LocalPackageInfo package)
        {
            lock (syncLock)
            {
                // already downloading? ignore
                if (downloads.Contains(package))
                {
                    return;
                }

                // marked for delete? ignore
                if (package.LockProvider.IsMarkedToDelete)
                {
                    return;
                }

                // already downloaded? ignore
                if (package.DownloadStatus.IsDownloaded)
                {
                    return;
                }

                // mark as "Resume download"
                if (!package.DownloadStatus.Data.IsDownloading)
                {
                    package.DownloadStatus.Data.IsDownloading = true;
                    packageRegistry.UpdateDownloadStatus(package);
                }

                // start download
                UpdateQueue(package, isInterested: true);
            }

            DownloadStatusChange?.Invoke(new DownloadStatusChange()
            {
                Package = package, HasStarted = true
            });
        }