Example #1
0
        void OnFinished(object sender, HttpTask.FinishedEventArgs args)
        {
            if (!args.Cancelled)
            {
                Task Download = mDownloads[mCurrentTask];
                if (args.ErrCode != 0)
                {
                    AppLog.Line("Download failed: {0}", args.GetError());
                    if (File.Exists(mCurTask.DlPath + @"\" + mCurTask.DlName))
                    {
                        AppLog.Line("An older version is present and will be used.");
                    }
                    else
                    {
                        Download.Failed = true;
                    }
                }

                Download.FileName        = mCurTask.DlName;
                mDownloads[mCurrentTask] = Download;
                mCurTask = null;

                mCurrentTask++;
            }
            else
            {
                mCurrentTask = -1;
            }
            DownloadNextFile();
        }
Example #2
0
        void OnFinished(object sender, HttpTask.FinishedEventArgs args)
        {
            DomainBlocklist Blocklist;

            ListLock.EnterReadLock();
            Blocklists.TryGetValue(mCurTask.DlUrl, out Blocklist);
            ListLock.ExitReadLock();

            if (Blocklist != null)
            {
                Blocklist.LastUpdate = DateTime.Now;

                if (!args.Cancelled)
                {
                    if (!args.Success)
                    {
                        Blocklist.Status = "Download Error"; // todo localize

                        App.LogError("Blocklist download failed: {0}; Reason: {1}", mCurTask.DlUrl, args.GetError());
                        if (mCurTask.DlName != null && File.Exists(mCurTask.DlPath + @"\" + mCurTask.DlName))
                        {
                            App.LogWarning("An older version of the Blocklist is present and will be used.");
                        }
                    }
                    else
                    {
                        Blocklist.Status = "Downloaded"; // todo localize
                    }
                }
            }

            PendingDownloads.Remove(mCurTask.DlUrl);
            mCurTask = null;
            DownloadNextFile();
        }