/// </summary>\r
public void loadCurrentPref()\r
{\r
- this.RepositoriesListSetting = NaGet.Utils.GetDeserializedObject<RepositoriesList>(NaGet.Env.RepositoriesListFile);\r
+ try {\r
+ this.RepositoriesListSetting = NaGet.Utils.GetDeserializedObject<RepositoriesList>(NaGet.Env.RepositoriesListFile);\r
+ } catch {\r
+ this.RepositoriesListSetting = new RepositoriesList();\r
+ }\r
\r
NaGet.NaGetLibPref userPref = NaGet.Env.Pref;\r
this.ProxyAddress = userPref.ProxyAddress;\r
--- /dev/null
+using System;
+using System.IO;
+
+namespace NaGet.Packages
+{
+ /// <summary>
+ /// パッケージ情報のファイルアクセスに関する例外
+ /// </summary>
+ public class PackageInformationFileAccessException : ApplicationException
+ {
+ string filePath;
+
+ public PackageInformationFileAccessException(string msg, string filepath, Exception innerException)
+ : base(msg, innerException)
+ {
+ this.filePath = filepath;
+ }
+
+ /// <summary>
+ /// パッケージ情報のファイルへのパス
+ /// </summary>
+ public string FilePath {
+ get { return filePath; }
+ }
+ }
+}
foreach (string path in NaGet.Utils.ExtendWildcardFile(NaGet.Env.ArchiveProgramFiles, Path.Combine("*", ".applistation.package.xml"))) {\r
try {\r
pkgList.AddPackage(NaGet.Utils.GetDeserializedObject<InstalledPackage>(path));\r
- } catch (Exception) {\r
+ } catch (Exception e) {\r
+ throw new PackageInformationFileAccessException(\r
+ string.Format("The information file of {0} is broken.", path),\r
+ path, e);\r
}\r
}\r
this.installedPkgList = pkgList;\r
using System;
+using System.IO;
using NaGet.Tasks;
using NaGet.Packages;
NotifyStarted();
RaiseTaskSetEvent(TaskEventType.STARTED, "インストール済みファイルリスト更新", 0);
- pkgListMan.DetectInstalledPkgs();
+ try {
+ pkgListMan.DetectInstalledPkgs();
+ } catch (PackageInformationFileAccessException e) {
+ recoverExceptionAtDetectInstalledPkgs(e);
+ }
pkgListMan.SaveInstalledPackageList();
RaiseTaskSetEvent(TaskEventType.INFO, string.Format("{0} を更新しました", NaGet.Env.ArchiveInstalledPackageListFile), 50);
RaiseTaskSetEvent(TaskEventType.COMPLETED, "インストール済みファイルリスト更新", 100);
NotifyCompleted();
}
+
+ private void recoverExceptionAtDetectInstalledPkgs(PackageInformationFileAccessException e)
+ {
+ RaiseTaskSetEvent(TaskEventType.WARNING, string.Format("{0} が読み込めませんでした", e.FilePath), -1);
+
+ string dirPath = Path.GetDirectoryName(e.FilePath);
+ if (Directory.Exists(dirPath)) {
+ NaGet.Utils.SetAttributeRecursive(dirPath, FileAttributes.Normal);
+ Directory.Delete(dirPath, true);
+ RaiseTaskSetEvent(TaskEventType.WARNING, string.Format("{0}を削除しました。", Path.GetDirectoryName(e.FilePath)), -1);
+
+ pkgListMan.DetectInstalledPkgs();
+ } else {
+ throw e;
+ }
+ }
}
}
<Compile Include="NaGet.Packages.Install\InstallationLog.cs" />\r
<Compile Include="NaGet.Packages.Install\UpgradeFinder.cs" />\r
<Compile Include="NaGet.Packages\PackageCollectionFileData.cs" />\r
+ <Compile Include="NaGet.Packages\PackageInformationFileAccessException.cs" />\r
<Compile Include="NaGet.Packages\PackageListsManager.cs" />\r
<Compile Include="NaGet.Packages\RepositoriesList.cs" />\r
<Compile Include="NaGet.Packages\VersionComparetor.cs" />\r