Browse Source

Minor change in backup process that makes it not store zero-size files

pull/13/head
Anairkoen Schno 5 years ago
parent
commit
afb5822e77
2 changed files with 15 additions and 19 deletions
  1. +3
    -2
      IPA.Injector/Backups/BackupUnit.cs
  2. +12
    -17
      IPA/Patcher/BackupUnit.cs

+ 3
- 2
IPA.Injector/Backups/BackupUnit.cs View File

@ -35,7 +35,7 @@ namespace IPA.Injector.Backups
if (unit._manifestFile.Exists) if (unit._manifestFile.Exists)
{ {
var manifest = File.ReadAllText(unit._manifestFile.FullName); var manifest = File.ReadAllText(unit._manifestFile.FullName);
foreach (var line in manifest.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
foreach (var line in manifest.Split(new[] { Environment.NewLine, "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries))
unit._files.Add(line); unit._files.Add(line);
} }
else else
@ -81,7 +81,8 @@ namespace IPA.Injector.Backups
else else
{ {
// Make empty file // Make empty file
backupPath.Create().Close();
//backupPath.Create().Close();
// do not do this because it can cause problems
} }
if (_files.Contains(relativePath)) return; if (_files.Contains(relativePath)) return;


+ 12
- 17
IPA/Patcher/BackupUnit.cs View File

@ -93,7 +93,8 @@ namespace IPA.Patcher
else else
{ {
// Make empty file // Make empty file
backupPath.Create().Close();
//backupPath.Create().Close();
// don't do this bc its dumb
} }
if (!File.Exists(_manifestFile.FullName)) if (!File.Exists(_manifestFile.FullName))
@ -118,25 +119,19 @@ namespace IPA.Patcher
var backupFile = new FileInfo(Path.Combine(_backupPath.FullName, relativePath)); var backupFile = new FileInfo(Path.Combine(_backupPath.FullName, relativePath));
var target = new FileInfo(Path.Combine(_context.ProjectRoot, relativePath)); var target = new FileInfo(Path.Combine(_context.ProjectRoot, relativePath));
if (backupFile.Exists)
if (backupFile.Exists && backupFile.Length > 0)
{ {
if (backupFile.Length > 0)
{
Console.WriteLine(" {0} => {1}", backupFile.FullName, target.FullName);
target.Directory?.Create();
backupFile.CopyTo(target.FullName, true);
}
else
Console.WriteLine(" {0} => {1}", backupFile.FullName, target.FullName);
target.Directory?.Create();
backupFile.CopyTo(target.FullName, true);
}
else
{
Console.WriteLine(" x {0}", target.FullName);
if(target.Exists)
{ {
Console.WriteLine(" x {0}", target.FullName);
if(target.Exists)
{
target.Delete();
}
target.Delete();
} }
} else
{
Console.Error.WriteLine("Backup not found!");
} }
} }
} }


Loading…
Cancel
Save