示例#1
0
        static void _AfterComplete(Session oSession)
        {
            if (!CacherSettings.Current.CacheEnabled)
            {
                return;
            }
            if (!_Filter(oSession))
            {
                return;
            }

            if (oSession.responseCode == 200)
            {
                string filepath = TaskRecord.GetAndRemove(oSession.fullUrl);

                if (!string.IsNullOrEmpty(filepath))
                {
                    if (File.Exists(filepath))
                    {
                        File.Delete(filepath);
                    }

                    //保存下载文件并记录Modified-Time
                    try
                    {
                        oSession.SaveResponseBody(filepath);
                        cache.RecordNewModifiedTime(oSession.fullUrl,
                                                    oSession.oResponse.headers["Last-Modified"]);

                        //Debug.WriteLine("CACHR> 【下载文件】" + oSession.PathAndQuery);
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(oSession, ex, "会话结束时,保存返回文件时发生异常");
                    }
                }
            }
        }
示例#2
0
 void _RecordTask(string url, string filepath)
 {
     TaskRecord.Add(url, filepath);
 }