Skip to content

Commit

Permalink
Merge branch 'InstallLogRevert'
Browse files Browse the repository at this point in the history
  • Loading branch information
prideslayer committed Mar 30, 2014
2 parents aaf3d7d + 16e1149 commit 3a53937
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
3 changes: 2 additions & 1 deletion GeMod.Interface/GeMod.Interface.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GeMod.Interface</RootNamespace>
<AssemblyName>GeMod.Interface</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion GeMod.Interface/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup/></configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
3 changes: 2 additions & 1 deletion Transactions/Transactions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>fomm.Transactions</RootNamespace>
<AssemblyName>fomm.Transactions</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion Transactions/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup/></configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
125 changes: 125 additions & 0 deletions flmm/InstallLogUpgraders/Downgrader0500.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Fomm.PackageManager;
using Fomm.PackageManager.ModInstallLog;

namespace Fomm.InstallLogUpgraders
{
/// <summary>
/// Upgrades the Install Log to the current version from version 0.1.1.0.
/// </summary>
internal class Downgrader0500 : Upgrader
{
/// <summary>
/// Downgrades the Install Log to the current version from version 5.0.0.0.
/// </summary>
/// <remarks>
/// NMM pointlessly changed the XML format in a way incompatible with FOMM
/// without a lot of effort. Since it will painlessly (and silently) update
/// this file to 0.5.0.0 if needed, we will (not silently) bring it back
/// down to 0.2.0.0 if needed.
/// </remarks>
protected override void DoUpgrade()
{
/*
Converts the modList entries from
<mod key="x2hrojjw" path="Dummy Mod: ORIGINAL_VALUES">
<version machineVersion="0">0</version>
<name>ORIGINAL_VALUES</name>
<installDate>03/30/2014 00:00:00</installDate>
</mod>
TO
<mod name="the mod configuration menu" key="qdq0aqvc">
<version machineVersion="1.5">1.5</version>
</mod>
*** This copies the name element value into the name property of the mod tag and deletes the 'path' property,
*** then deletes the name and installdate elements.
Converts the dataFiles entries from
<file path="data\test.esp">
<installingMods>
<mod key="qlyv0rki" />
</installingMods>
</file>
TO
<file path="test.esp">
<installingMods>
<mod key="qlyv0rki" />
</installingMods>
</file>
*** This is simply removing 'data\' from the path in each file element.
*/
XDocument doc = null;
XElement root = null;
XElement modlist = null;
XElement datafiles = null;
IList<string> lstMods;
fomod fomodMod = null;
string strModPath;

// Load the document
doc = XDocument.Load(InstallLog.Current.InstallLogPath);
root = doc.Element("installLog");
modlist = root.Element("modList");
datafiles = root.Element("dataFiles");

// Set current version
root.SetAttributeValue("fileVersion", InstallLog.CURRENT_VERSION);

// Reset datafile entries
foreach (XElement el in datafiles.Descendants("file"))
{
// Check to see that data is set as the first path element. If not, throw an exception
// indicating that the user should disable that mod with NMM and try again -- FOMM cannot
// presently uninstall/deactivate mods that operate in the game folder above the data
// folder.

string strPath = el.Attribute("path").Value.ToLowerInvariant();
string strData = "data" + Path.DirectorySeparatorChar;
strPath = strPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
if (strPath.IndexOf(strData) == 0)
{
strPath = strPath.Substring(strData.Length);
el.SetAttributeValue("path", strPath);
}
else
{
throw new Exception(
"NMM or another mod manager installed the file " + strPath + " which FOMM cannot uninstall.\n" +
"The upgrade cannot proceed.\nPlease deactivate the mod which installed that file in NMM and try again."
);
}
}

// Reset mod entries
foreach (XElement el in modlist.Descendants("mod"))
{
// Set name attribute equal to name element value
el.SetAttributeValue("name", el.Element("name").Value);

// Remove path attribute
el.SetAttributeValue("path", null);

// Remove name element
el.Element("name").Remove();

// Remove installdate element
el.Element("installDate").Remove();

// Handle MMV
if (el.Attribute("name").Value == "MOD_MANAGER_VALUE")
{
el.SetAttributeValue("name", InstallLog.FOMM);
}
}

doc.Save(InstallLog.Current.InstallLogPath);
}
}
}
7 changes: 5 additions & 2 deletions flmm/InstallLogUpgraders/InstallLogUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Fomm.InstallLogUpgraders
{
/// <summary>
/// Upgrades the install log.
/// Reverts the InstallLog to 2.0.0.0.
/// </summary>
internal class InstallLogUpgrader
{
Expand All @@ -28,6 +28,7 @@ internal InstallLogUpgrader()
m_dicUpgraders[new Version("0.0.0.0")] = new Upgrader0000();
m_dicUpgraders[new Version("0.1.0.0")] = new Upgrader0100();
m_dicUpgraders[new Version("0.1.1.0")] = new Upgrader0110();
m_dicUpgraders[new Version("0.5.0.0")] = new Downgrader0500();
}

/// <summary>
Expand Down Expand Up @@ -64,7 +65,9 @@ public bool UpgradeInstallLog()
{
InstallLog.Current.EnableLogFileRefresh = false;
if (!m_dicUpgraders.ContainsKey(verOldVersion))
throw new InvalidOperationException("No upgrader for Install Log Version " + verOldVersion + ".");
{
throw new InvalidOperationException("No upgrade or downgrade available for Install Log Version " + verOldVersion + ".");
}

booUpgraded = m_dicUpgraders[verOldVersion].PerformUpgrade();
InstallLog.Current.EnableLogFileRefresh = true;
Expand Down
14 changes: 4 additions & 10 deletions flmm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class fommException : Exception { public fommException(string msg) : base(msg) {

public static class Program
{
public const string Version = "0.14.10.1";
public const string Version = "0.14.10.2";
public static readonly Version MVersion = new Version(Version);

private static readonly string m_strExecutableDirectory = Path.GetDirectoryName(Application.ExecutablePath);
Expand Down Expand Up @@ -378,16 +378,8 @@ private static void Main(string[] args)
return;
PermissionsManager.Init();

if (InstallLog.Current.GetInstallLogVersion() > InstallLog.CURRENT_VERSION)
{
MessageBox.Show("You have run another mod manager, likely NMM, that has corrupted InstallLog.xml. Delete InstallLog.xml in '" + Program.GameMode.InstallInfoDirectory + "' and rename one of the backups there to fix.", "NMM Douchebaggery");
return;
}

InstallLog.Reload();

//check to see if we need to upgrade the install log format
if (InstallLog.Current.GetInstallLogVersion() < InstallLog.CURRENT_VERSION)
if (InstallLog.Current.GetInstallLogVersion() != InstallLog.CURRENT_VERSION)
{
InstallLogUpgrader iluUgrader = new InstallLogUpgrader();
try
Expand All @@ -406,6 +398,8 @@ private static void Main(string[] args)
}
}

InstallLog.Reload();

//let's uninstall any fomods that have been deleted since we last ran
IList<FomodInfo> lstMods = InstallLog.Current.GetVersionedModList();
foreach (FomodInfo fifMod in lstMods)
Expand Down
Loading

0 comments on commit 3a53937

Please sign in to comment.