示例#1
0
文件: Thread.cs 项目: omega227/DeanCC
        /// <summary>
        /// 画像を保存する直前に呼び出されます
        /// </summary>
        protected virtual void OnImageSaving(ImageSaveEventArgs e)
        {
            if (e.DownloadResult.Status != ImageDownloadResultStatus.Success)
            {
                e.Cancel = true;
                return;
            }
            lock (((System.Collections.ICollection)Common.DownloadedImageHashes).SyncRoot)
            {
                if (Common.Options.ImageSaveOptions.BlockDownloadedImage &&
                    Common.DownloadedImageHashes.Any(hash =>
                        hash.MD5Hash.Equals(e.ImageHeader.MD5Hash, StringComparison.CurrentCultureIgnoreCase)))
                {
                    e.ImageHeader.State = ImageState.RepeatedDownload;
                    e.Cancel = true;
                    return;
                }
            }
            if (Common.NGFiles != null && Common.NGFiles.Exists(e.ImageHeader.MD5Hash))
            {
                e.ImageHeader.State = ImageState.NGFile;
                e.Cancel = true;
                return;
            }

            if (ImageSaving != null)
            {
                ImageSaving(this, e);
            }
        }
示例#2
0
文件: Thread.cs 项目: omega227/DeanCC
        private void Save(ImageDownloadResult result, IImageHeader destination)
        {
            ImageSaveEventArgs e = new ImageSaveEventArgs(result, destination);
            OnImageSaving(e);
            if (e.Cancel)
            {
                return;
            }

            if (Common.Options.BrowsersOptions.JaneOptions.SavableImage)
            {
                string saveFolder = destination.IsZip && !Common.Options.ZipOptions.SavesSameImagesFolder ?
                    Common.Options.ZipOptions.DefaultSaveFolder : header.ImageSaveFolder;
                string fileNameFormat = Common.Options.ImageSaveOptions.FileNameFormat;
                fileNameFormat = header.Format(fileNameFormat);
                destination.Save(result.Data, saveFolder, fileNameFormat);
            }
            if (Common.Options.BrowsersOptions.JaneOptions.SavableCache && Common.ViewCacher != null)
            {
                Common.ViewCacher.Save(
                    result.Data, result.ContentType, result.LastModified, result.Url, result.Referer, header.Url);
            }
            OnImageSaved(e);
        }
示例#3
0
文件: Thread.cs 项目: omega227/DeanCC
 /// <summary>
 /// 画像を保存した直後に呼び出されます
 /// 保存しなかった場合は呼び出されません
 /// </summary>
 protected virtual void OnImageSaved(ImageSaveEventArgs e)
 {
     lock (((System.Collections.ICollection)Common.DownloadedImageHashes).SyncRoot)
     {
         Common.DownloadedImageHashes.Add(new ImageHash(e.ImageHeader.MD5Hash, e.ImageHeader.SavedPath));
     }
     header.DownloadedCount++;
     lastImageModified = DateTime.Now;
     Common.CurrentSettings.Information.TotalSavedImageCount++;
     if (Common.Options.ImageSaveOptions.ApplyOriginalTimestamp)
     {
         File.SetLastAccessTime(e.ImageHeader.SavedPath, e.DownloadResult.LastModified);
     }
     if (ImageSaved != null)
     {
         ImageSaved(this, e);
     }
 }