X-Git-Url: http://git.sourceforge.jp/view?p=applistation%2FAppliStation.git;a=blobdiff_plain;f=na-get-lib%2FNaGet.SubCommands%2FNaGetInstall.cs;h=390f1a0a7d6f91f0546f6cddd6499904e0fdbbbd;hp=037242c44ad36578499bf715e21784dc1ed62b77;hb=76ea75be843be4d33ed9233162c4542096e3ffb6;hpb=54bfd41d4ba08ef4d8f0e0d583d6c3f3346fd086;ds=sidebyside diff --git a/na-get-lib/NaGet.SubCommands/NaGetInstall.cs b/na-get-lib/NaGet.SubCommands/NaGetInstall.cs index 037242c..390f1a0 100644 --- a/na-get-lib/NaGet.SubCommands/NaGetInstall.cs +++ b/na-get-lib/NaGet.SubCommands/NaGetInstall.cs @@ -21,6 +21,11 @@ namespace NaGet.SubCommands get { if (downloader == null) { downloader = new Downloader(); + downloader.DownloadEventRaised += delegate(object sender, DownloadEventArgs e) { + if (e.Type == DownloadEventType.DOWNLOADING && e.TaskProgressPercent > 0) { + RaiseTaskSetEvent(NaGetTaskSetEventType.PING, string.Empty, GetProgressPercent(NaGetTaskSetEventType.PING, e.TaskProgressPercent)); + } + }; } return downloader; } @@ -68,7 +73,7 @@ namespace NaGet.SubCommands taskSetNames.Add(string.Format("取得: {0}", Installations[i].ToString())); taskSetNames.Add(string.Format("ウイルススキャン: {0}", Installations[i].ToString())); } - taskSetNames.Add("インストーラの検証"); + taskSetNames.Add("インストーラーの検証"); for (int i =0; i < Installations.Length; i++) { taskSetNames.Add(string.Format("インストール: {0}", Installations[i].ToString())); } @@ -87,7 +92,7 @@ namespace NaGet.SubCommands // ハッシュ非適合なインストーラの表 List invalidInstallers = null; - while (invalidInstallers == null || invalidInstallers.Count > 0) { + do { currentTaskSetIndex = 0; packageInstallerDownloaded = false; @@ -99,7 +104,7 @@ namespace NaGet.SubCommands RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]); - // ハッシュの壊れているインストーラを取得 + // ハッシュの壊れているインストーラーを取得 invalidInstallers = runCheckHashForInstaller(); // ハッシュが壊れているときの対策 @@ -139,9 +144,11 @@ namespace NaGet.SubCommands return; } } - currentTaskSetIndex ++; - RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex-1]); - } + + // もしハッシュが不適合なソフトがあるならばダウンロード処理からやり直す + } while (invalidInstallers == null || invalidInstallers.Count > 0); + RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]); + currentTaskSetIndex ++; } foreach (Installation inst in Installations) { @@ -158,7 +165,7 @@ namespace NaGet.SubCommands inst.OutputDataReceived += this.ReceivedOutputData; int exitCode = inst.Install(); if (exitCode != 0) { - RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, "インストールが正常に終えていない可能性があります。インストーラの終了コード:"+exitCode); + RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, "インストールが正常に終えていない可能性があります。プロセスの終了コード:"+exitCode); } pkgListMan.WriteInstallationLog(inst); @@ -167,9 +174,8 @@ namespace NaGet.SubCommands done = true; return; } - currentTaskSetIndex ++; - RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, installTaskMsg); + currentTaskSetIndex ++; if (cancelCalled) { RaiseTaskSetEvent(NaGetTaskSetEventType.CANCELED, "パッケージのインストール処理がキャンセルされました"); @@ -177,7 +183,6 @@ namespace NaGet.SubCommands return; } } - pkgListMan.SaveSystemInstalledLogList(); // ログのコミット runLocalUpdate(); @@ -209,7 +214,7 @@ namespace NaGet.SubCommands try { inst.Download(Downloader); } catch (NaGetTaskCanceledException) { - RaiseTaskSetEvent(NaGetTaskSetEventType.CANCELED, "インストーラのダウンロード処理がキャンセルされました"); + RaiseTaskSetEvent(NaGetTaskSetEventType.CANCELED, "インストーラーのダウンロード処理がキャンセルされました"); done = true; return; } catch (System.Net.WebException e) { @@ -227,24 +232,43 @@ namespace NaGet.SubCommands return; } } - currentTaskSetIndex ++; - if (inst.Downloaded) { // 正常終了 - RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex-1]); - } else { // インストールが完了せずに終わった=失敗=エラー - RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, string.Format("{0}のインストーラを正常にダウンロードできませんでした", inst.ToString())); + if (! inst.Downloaded) { // インストールが完了せずに終わった=失敗=エラー + RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, string.Format("{0}のインストーラーファイルを正常にダウンロードできませんでした", inst.ToString())); done = true; return; } + RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]); + currentTaskSetIndex ++; RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]); if (! NaGet.Env.EnableScanInstallerFile) { - RaiseTaskSetEvent(NaGetTaskSetEventType.INFO, string.Format("ウイルススキャンを行わない設定のため、ダウンロードしたファイルはウイルススキャンされませんでした")); + RaiseTaskSetEvent(NaGetTaskSetEventType.INFO, "ウイルススキャンを行わない設定のため、ダウンロードしたファイルはウイルススキャンされませんでした"); } else if (!scanner.HasScanner) { - RaiseTaskSetEvent(NaGetTaskSetEventType.INFO, string.Format("ダウンロードしたファイルはウイルススキャンされませんでした(ウイルススキャンソフトが検出できませんでした)")); + RaiseTaskSetEvent(NaGetTaskSetEventType.INFO, "ダウンロードしたファイルはウイルススキャンされませんでした(ウイルススキャンソフトが検出できませんでした)"); } else { try { - inst.ScanInstallerFile(scanner); + DownloadScannerResult result = inst.ScanInstallerFile(scanner); + + switch (result) { + case DownloadScannerResult.ScannerNotFound: + RaiseTaskSetEvent(NaGetTaskSetEventType.INFO, "ダウンロードしたファイルはウイルススキャンされませんでした(ウイルススキャンソフトが検出できませんでした)"); + break; + case DownloadScannerResult.InfectedAndCleaned: + RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, + "インストーラーファイルからウイルス感染が検出されたため、削除されました。"); + done = true; + return; + case DownloadScannerResult.InfectedButNotCleaned: + RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, + "インストーラーファイルからウイルス感染が検出されました。"); + done = true; + break; + case DownloadScannerResult.ErrorNotFound: + throw new System.IO.FileNotFoundException(string.Empty); + //break; + } + } catch (System.Runtime.InteropServices.COMException ex) { RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, string.Format("{0} (E{1})", ex.Message, ex.ErrorCode)); @@ -253,13 +277,13 @@ namespace NaGet.SubCommands RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, string.Format("{0} (E{1})", ex.InnerException.Message, ((System.Runtime.InteropServices.COMException) ex.InnerException).ErrorCode)); } - RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, "インストーラがウイルススキャナによって削除されました。"); + RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, "インストーラーファイルがウイルススキャナーによって削除されました。"); done = true; return; } } + RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]); currentTaskSetIndex ++; - RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex-1]); if (cancelCalled) { RaiseTaskSetEvent(NaGetTaskSetEventType.CANCELED, "パッケージのインストール処理がキャンセルされました"); @@ -273,7 +297,7 @@ namespace NaGet.SubCommands /// /// ダウンロードしたパッケージが整合したか否かハッシュでチェック /// - /// 整合しなかったインストーラのリスト + /// 整合しなかったインストーラーのリスト private List runCheckHashForInstaller() { List invalidInstallers = new List(); @@ -304,15 +328,15 @@ namespace NaGet.SubCommands RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]); pkgListMan.DetectInstalledPkgs(); pkgListMan.SaveInstalledPackageList(); + RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]); currentTaskSetIndex++; - RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex-1]); // システムにインストールされているリストの更新 RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]); pkgListMan.DetectSystemInstalledPkgs(); pkgListMan.SaveSystemInstalledPackageList(); + RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]); currentTaskSetIndex++; - RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex-1]); } public override bool Done {