OSDN Git Service

AppliStation-All,インストール処理を新方式(NaGetInstall2)に変更。
[applistation/AppliStation.git] / na-get-lib / NaGet.SubCommands.SubTask / VerifyInstallerFileSubTask.cs
1 using System;
2 using System.Collections.Generic;
3 using NaGet.Tasks;
4 using NaGet.Packages;
5 using NaGet.Packages.Install;
6
7 namespace NaGet.SubCommands.SubTask
8 {
9         public class VerifyInstallerFileSubTask : NaGetSubTask
10         {
11                 IList<Installation> installations = null;
12                 
13                 IList<Installation> invalidInstallers = null;
14                 
15                 public VerifyInstallerFileSubTask(IList<Installation> insts)
16                 {
17                         installations = insts;
18                 }
19                 
20                 public IList<Installation> InvalidInstallers {
21                         get { return invalidInstallers; }
22                 }
23                 
24                 public override void Run()
25                 {
26                         NotifyStarted();
27                         
28                         List<Installation> invalidInstallers = new List<Installation>();
29                         
30                         for (int i = 0; i < installations.Count; i++) {
31                                 Installation inst = installations[i];
32                                 float percent = 100.0f * i / installations.Count;
33                                 
34                                 if (inst.GetRegisteredHashCount() > 0) {
35                                         if (inst.IsInstallablePackage() && inst.VerifyHashValues() == false) {
36                                                 invalidInstallers.Add(inst);
37                                                 RaiseTaskSetEvent(TaskEventType.WARNING, "検証: "+inst.ToString() + " 非整合", percent);
38                                         } else {
39                                                 RaiseTaskSetEvent(TaskEventType.INFO, "検証: "+inst.ToString() + " OK", percent);
40                                         }
41                                 } else {
42                                         RaiseTaskSetEvent(TaskEventType.PING, string.Empty, percent);
43                                 }
44                         }
45                         
46                         if (invalidInstallers.Count > 0) {
47                                 this.invalidInstallers = invalidInstallers.AsReadOnly();
48                         } else {
49                                 this.invalidInstallers = null;
50                         }
51                         
52                         NotifyCompleted();
53                 }
54         }
55 }