OSDN Git Service

na-get-lib,レポジトリに不正なURLが記述したとき、エラーが発生し異常終了する不具合を修正。
authorttp <ttp@users.sourceforge.jp>
Sun, 13 Dec 2009 06:34:26 +0000 (15:34 +0900)
committerttp <ttp@users.sourceforge.jp>
Sun, 13 Dec 2009 06:34:26 +0000 (15:34 +0900)
このとき、エラーメッセージを表示した上で、ソフトリストのインストールを行わないような動作に変更した。

na-get-lib/NaGet.SubCommands/NaGetUpdate.cs

index f105971..d16011d 100644 (file)
@@ -117,29 +117,32 @@ namespace NaGet.SubCommands
                        foreach(RepositoryInfo repo in repoList.EnabledRepositories) {\r
                                RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]);\r
                                \r
-                               string tmpfileName = Path.GetTempFileName();\r
-                               try {\r
-                                       Downloader.Download(repo.Url.Href, tmpfileName);\r
-                                       \r
-                                       if (repo.Type == RepositoryType.APPLISTATION_NATIVE_XML_1_0) {\r
-                                               try {\r
-                                                       PackageList<Package> pkgList = NaGet.Utils.GetDeserializedObject<PackageList<Package>>(tmpfileName);\r
-                                                       pkgList.FixPackageListName(); // PackageListNameとの紐付けを行う\r
-                                                       \r
-                                                       // RepositoryReferenceの名前を読み込む // TODO RepositoryReferenceの名前を読み込む処理はここでいいのか?\r
-                                                       repo.Name = (string.IsNullOrEmpty(pkgList.Name))? repo.Name : pkgList.Name;\r
-                                                       \r
-                                                       avaiablePackageList.AddPackages(pkgList);\r
-                                               } catch (InvalidOperationException) {\r
-                                                       RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, string.Format("Repository {0} does not have a AppliStation Native XML softlist.", repo.Name ?? repo.Url.Href));\r
+                               if (Uri.IsWellFormedUriString(repo.Url.Href, UriKind.Absolute)) {\r
+                                       string tmpfileName = Path.GetTempFileName();\r
+                                       try {\r
+                                               Downloader.Download(repo.Url.Href, tmpfileName);\r
+                                               if (repo.Type == RepositoryType.APPLISTATION_NATIVE_XML_1_0) {\r
+                                                       try {\r
+                                                               PackageList<Package> pkgList = NaGet.Utils.GetDeserializedObject<PackageList<Package>>(tmpfileName);\r
+                                                               pkgList.FixPackageListName(); // PackageListNameとの紐付けを行う\r
+                                                               \r
+                                                               // RepositoryReferenceの名前を読み込む // TODO RepositoryReferenceの名前を読み込む処理はここでいいのか?\r
+                                                               repo.Name = (string.IsNullOrEmpty(pkgList.Name))? repo.Name : pkgList.Name;\r
+                                                               \r
+                                                               avaiablePackageList.AddPackages(pkgList);\r
+                                                       } catch (InvalidOperationException) {\r
+                                                               RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, string.Format("レポジトリ'{0}'はAppliStation Native XML softlist形式ではありません。", repo.Name ?? repo.Url.Href));\r
+                                                       }\r
+                                               } else {\r
+                                                       RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, string.Format("レポジトリ'{0}'の設定が不正です。", repo.Name ?? repo.Url.Href));\r
+                                               }\r
+                                       } finally {\r
+                                               if (File.Exists(tmpfileName)) {\r
+                                                       File.Delete(tmpfileName);\r
                                                }\r
-                                       } else {\r
-                                               RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, string.Format("Repository {0} is illegal type.", repo.Name ?? repo.Url.Href));\r
-                                       }\r
-                               } finally {\r
-                                       if (File.Exists(tmpfileName)) {\r
-                                               File.Delete(tmpfileName);\r
                                        }\r
+                               } else {\r
+                                       RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, string.Format("レポジトリ'{0}'のURLが不正なため、ソフトリストは取得できませんでした。", repo.Name ?? repo.Url.Href));\r
                                }\r
                                \r
                                currentTaskSetIndex ++;\r