mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Clone the modlist so we don't delete everything on a re-install
This commit is contained in:
parent
b8a6db5211
commit
38f4825099
@ -365,16 +365,26 @@ namespace Wabbajack.Common
|
|||||||
|
|
||||||
public static void ToCERAS<T>(this T obj, string filename, SerializerConfig config)
|
public static void ToCERAS<T>(this T obj, string filename, SerializerConfig config)
|
||||||
{
|
{
|
||||||
|
byte[] final;
|
||||||
|
final = ToCERAS(obj, config);
|
||||||
|
File.WriteAllBytes(filename, final);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] ToCERAS<T>(this T obj, SerializerConfig config)
|
||||||
|
{
|
||||||
|
byte[] final;
|
||||||
var ceras = new CerasSerializer(config);
|
var ceras = new CerasSerializer(config);
|
||||||
byte[] buffer = null;
|
byte[] buffer = null;
|
||||||
ceras.Serialize(obj, ref buffer);
|
ceras.Serialize(obj, ref buffer);
|
||||||
|
|
||||||
using (var m1 = new MemoryStream(buffer))
|
using (var m1 = new MemoryStream(buffer))
|
||||||
using (var m2 = new MemoryStream())
|
using (var m2 = new MemoryStream())
|
||||||
{
|
{
|
||||||
BZip2.Compress(m1, m2, false, 9);
|
BZip2.Compress(m1, m2, false, 9);
|
||||||
m2.Seek(0, SeekOrigin.Begin);
|
m2.Seek(0, SeekOrigin.Begin);
|
||||||
File.WriteAllBytes(filename, m2.ToArray());
|
final = m2.ToArray();
|
||||||
}
|
}
|
||||||
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T FromCERAS<T>(this Stream data, SerializerConfig config)
|
public static T FromCERAS<T>(this Stream data, SerializerConfig config)
|
||||||
|
@ -344,6 +344,10 @@ namespace Wabbajack.Lib
|
|||||||
public async Task OptimizeModlist()
|
public async Task OptimizeModlist()
|
||||||
{
|
{
|
||||||
Utils.Log("Optimizing Modlist directives");
|
Utils.Log("Optimizing Modlist directives");
|
||||||
|
|
||||||
|
// Clone the modlist so our changes don't modify the original data
|
||||||
|
ModList = ModList.Clone();
|
||||||
|
|
||||||
var indexed = ModList.Directives.ToDictionary(d => d.To);
|
var indexed = ModList.Directives.ToDictionary(d => d.To);
|
||||||
|
|
||||||
UpdateTracker.NextStep("Looking for files to delete");
|
UpdateTracker.NextStep("Looking for files to delete");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Ceras;
|
using Ceras;
|
||||||
using Compression.BSA;
|
using Compression.BSA;
|
||||||
@ -120,6 +121,11 @@ namespace Wabbajack.Lib
|
|||||||
/// Whether readme is a website
|
/// Whether readme is a website
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ReadmeIsWebsite;
|
public bool ReadmeIsWebsite;
|
||||||
|
|
||||||
|
public ModList Clone()
|
||||||
|
{
|
||||||
|
return new MemoryStream(this.ToCERAS(CerasConfig.Config)).FromCERAS<ModList>(CerasConfig.Config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Directive
|
public class Directive
|
||||||
|
Loading…
x
Reference in New Issue
Block a user