Exemplo n.º 1
0
        private void CheckMD5AfterDownload(DownloadTask task)
        {
            //bool okay = true;

            string md5 = MD5Hash.GetFileMD5_lowercase(task.storagePath);

            if (md5 != task.md5)
            {
                _transferMgr.UpdateFileTransferProgress(task.file, 0L);
                CLogger.Log("DownloadThread::CheckMD5AfterDownload() - Downloaded file with wrong MD5 value! FilePath=" + task.storagePath);
                File.Delete(task.storagePath);
                //okay = false;  //delete it and download again

                NotifyResult(task, DownloadStatus.Fail, task.errorCode);
                Thread.Sleep(3000);
            }
            else
            {
                NotifyResult(task, DownloadStatus.Complete);
            }

            //if(okay)
            //{
            //	//if the file downloaded is a packed file by zip,unzip it
            //	if(task.storagePath.EndsWith(".zip"))
            //	{
            //		if(unzipPackedFile(task))
            //		{
            //			NotifyResult(task,DownloadStatus.Complete);
            //			_currentTask = null;
            //		}
            //		else
            //		{
            //			NotifyResult(task,DownloadStatus.Fail,task.errorCode);
            //			Thread.Sleep(3000);
            //		}
            //	}
            //	else
            //	{
            //		//set name of downloaded file from  temp to localpath
            //		if(File.Exists(task.storagePath))
            //		{
            //			File.Delete(task.storagePath);
            //		}
            //	        File.Move(temp,task.storagePath);
            //		NotifyResult(task,DownloadStatus.Complete);
            //		_currentTask = null;
            //	}
            //}
        }