OSDN Git Service

na-get-lib,起動高速化機能追加時にインストール済みソフトのバージョン認識がされていないことがあったのを修正。
authorttp <ttp@users.sourceforge.jp>
Wed, 23 Dec 2009 09:31:01 +0000 (18:31 +0900)
committerttp <ttp@users.sourceforge.jp>
Wed, 23 Dec 2009 09:31:01 +0000 (18:31 +0900)
na-get-lib/NaGet.Packages/PackageListsManager.cs
na-get-lib/NaGet.SubCommands/NaGetInstall.cs
na-get-lib/NaGet.SubCommands/NaGetUpdate.cs

index 861bc07..62c5aba 100644 (file)
@@ -37,11 +37,6 @@ namespace NaGet.Packages
                }\r
                \r
                /// <summary>\r
-               /// インストールログ\r
-               /// </summary>\r
-               private List<InstallationLog> systemInstalledLogList;\r
-               \r
-               /// <summary>\r
                /// 初期化をする。データの読み込みは明示的にLoadPackageLists()を呼び出さなければならない。\r
                /// </summary>\r
                public PackageListsManager()\r
@@ -49,7 +44,6 @@ namespace NaGet.Packages
                        availablePkgList = new PackageList<Package>();\r
                        installedPkgList = new PackageList<InstalledPackage>();\r
                        systemInstalledPkgList = new PackageList<InstalledPackage>();\r
-                       systemInstalledLogList = new List<InstallationLog>();\r
                }\r
                \r
                #region ファイル読み書き\r
@@ -82,15 +76,6 @@ namespace NaGet.Packages
                        } else {\r
                                systemInstalledPkgList = new PackageList<InstalledPackage>();\r
                        }\r
-                       \r
-                       sr = new System.Xml.Serialization.XmlSerializer(typeof(InstallationLog[]));\r
-                       if (File.Exists(NaGet.Env.SystemInstalledPackageLogFile)) {\r
-                               systemInstalledLogList = new List<InstallationLog>(\r
-                                       (InstallationLog[]) NaGet.Utils.GetDeserializedObject(NaGet.Env.SystemInstalledPackageLogFile, sr)\r
-                               );\r
-                       } else {\r
-                               systemInstalledLogList = new List<InstallationLog>();\r
-                       }\r
                }\r
                \r
                /// <summary>\r
@@ -117,14 +102,6 @@ namespace NaGet.Packages
                {\r
                        NaGet.Utils.PutSerializeObject(NaGet.Env.SystemInstalledPackageListFile, systemInstalledPkgList);\r
                }\r
-               /// <summary>\r
-               /// インストールログ\r
-               /// をファイルに書き込む。\r
-               /// </summary>\r
-               public void SaveSystemInstalledLogList()\r
-               {\r
-                       NaGet.Utils.PutSerializeObject(NaGet.Env.SystemInstalledPackageLogFile, systemInstalledLogList);\r
-               }\r
                \r
                /// <summary>\r
                /// 本オブジェクトの保有しているパッケージ情報の全てをファイルに書き出す。\r
@@ -134,8 +111,6 @@ namespace NaGet.Packages
                        SaveAvailablePackageList();\r
                        SaveInstalledPackageList();\r
                        SaveSystemInstalledPackageList();\r
-                       \r
-                       SaveSystemInstalledLogList();\r
                }\r
                \r
                #endregion\r
@@ -166,6 +141,8 @@ namespace NaGet.Packages
                public void DetectSystemInstalledPkgs()\r
                {\r
                        List<InstalledPackage> installedPkgList = new List<InstalledPackage>();\r
+                       List<InstallationLog>  systemInstalledLogList = getSystemInstallerLog();\r
+                       \r
                        installedPkgList.AddRange(RegistriedUninstallers.DetectInstalledPackages(availablePkgList));\r
                        \r
                        // インストールのログを見て可能な限りパッケージ情報を補完する。\r
@@ -231,6 +208,32 @@ namespace NaGet.Packages
                #region インストールログ関連\r
                \r
                /// <summary>\r
+               /// インストールログのリストを作って返す。\r
+               /// </summary>\r
+               /// <returns>インストールログのリスト</returns>\r
+               private List<InstallationLog> getSystemInstallerLog()\r
+               {\r
+                       List<InstallationLog> systemInstalledLogList;\r
+                       \r
+                       try {\r
+                               systemInstalledLogList = NaGet.Utils.GetDeserializedObject<List<InstallationLog>>(NaGet.Env.SystemInstalledPackageLogFile);\r
+                       } catch (Exception) {\r
+                               systemInstalledLogList = new List<InstallationLog>();   \r
+                       }\r
+                       \r
+                       return systemInstalledLogList;\r
+               }\r
+               \r
+               /// <summary>\r
+               /// インストールログを保存する。\r
+               /// </summary>\r
+               /// <param name="systemInstalledLogList">インストールログデータ</param>\r
+               private void setSystemInstallerLog(List<InstallationLog> systemInstalledLogList)\r
+               {\r
+                       NaGet.Utils.PutSerializeObject(NaGet.Env.SystemInstalledPackageLogFile, systemInstalledLogList);\r
+               }\r
+               \r
+               /// <summary>\r
                /// 指定パッケージ名に対応するログを判定するPredicate\r
                /// </summary>\r
                /// <param name="pkg">判定する指定パッケージ</param>\r
@@ -250,6 +253,8 @@ namespace NaGet.Packages
                /// <param name="inst">書き込むインストール情報</param>\r
                public void WriteInstallationLog(Installation inst)\r
                {\r
+                       List<InstallationLog> systemInstalledLogList = getSystemInstallerLog();\r
+                       \r
                        // 重複は削除\r
                        systemInstalledLogList.RemoveAll(createPackageNamePredicator(inst.InstalledPackage));\r
                        \r
@@ -258,6 +263,8 @@ namespace NaGet.Packages
                        newLog.Package = inst.InstalledPackage;\r
                        \r
                        systemInstalledLogList.Add(newLog);\r
+                       \r
+                       setSystemInstallerLog(systemInstalledLogList);\r
                }\r
                \r
                #endregion\r
index 05f0db1..719c512 100644 (file)
@@ -177,7 +177,6 @@ namespace NaGet.SubCommands
                                        return;\r
                                }\r
                        }\r
-                       pkgListMan.SaveSystemInstalledLogList(); // ログのコミット\r
                        \r
                        runLocalUpdate();\r
                        \r
index 9e7ce51..2e1c0a9 100644 (file)
@@ -86,7 +86,7 @@ namespace NaGet.SubCommands
                                if (downloadPackageLists) {\r
                                        packageListsDownloaded = false;\r
                                        try {\r
-                                               runDownloadPackages();\r
+                                               runDownloadPackageLists();\r
                                        } catch (NaGetTaskCanceledException) {\r
                                                RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, "リストのダウンロード処理がキャンセルされました");\r
                                                pkgListMan.LoadPackageLists();\r
@@ -113,7 +113,7 @@ namespace NaGet.SubCommands
                        RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED, "終了", 100);\r
                }\r
                \r
-               private void runDownloadPackages()\r
+               private void runDownloadPackageLists()\r
                {\r
                        PackageList<Package> avaiablePackageList = new PackageList<Package>();\r
                        foreach(RepositoryInfo repo in repoList.EnabledRepositories) {\r