Remove unnecessary removers, clarify hashes

This commit is contained in:
Matt Nadareski
2021-02-02 11:27:42 -08:00
parent c54b35db92
commit b93088c36e
5 changed files with 11 additions and 25 deletions

View File

@@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using SabreTools.Core;
using SabreTools.DatFiles;
using SabreTools.DatItems;
using SabreTools.DatItems.Formats;
@@ -67,8 +68,8 @@ have a current entry in the DAT index.";
DatFile df = DatFile.Create();
foreach (string dir in onlyDirs)
{
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.NonArchive);
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.All);
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.NonArchive, hashes: Hash.Standard);
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.All, hashes: Hash.Standard);
}
// Create an empty Dat for files that need to be rebuilt

View File

@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.IO;
using SabreTools.Core;
using SabreTools.DatFiles;
using SabreTools.DatTools;
using SabreTools.FileTypes;
using SabreTools.Filtering;
using SabreTools.Help;
using SabreTools.IO;
@@ -53,16 +53,7 @@ namespace RombaSharp.Features
DatFile datfile = DatFile.Create();
datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name;
datfile.Header.Description = description;
DatFromDir.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive);
Remover remover = new Remover();
remover.PopulateExclusionsFromList(new List<string>
{
"DatItem.SHA256",
"DatItem.SHA384",
"DatItem.SHA512",
"DatItem.SpamSum",
});
remover.ApplyRemovals(datfile);
DatFromDir.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive, hashes: Hash.Standard);
Writer.Write(datfile, outdat);
}
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using SabreTools.Core;
using SabreTools.DatFiles;
using SabreTools.DatItems;
using SabreTools.DatItems.Formats;
@@ -65,7 +66,7 @@ contents of any changed dats.";
// First get a list of SHA-1's from the input DATs
DatFile datroot = DatFile.Create();
datroot.Header.Type = "SuperDAT";
DatFromDir.PopulateFromDir(datroot, _dats, asFiles: TreatAsFile.NonArchive);
DatFromDir.PopulateFromDir(datroot, _dats, asFiles: TreatAsFile.NonArchive, hashes: Hash.Standard);
datroot.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
// Create a List of dat hashes in the database (SHA-1)

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using SabreTools.Core;
using SabreTools.DatFiles;
using SabreTools.DatItems;
using SabreTools.DatItems.Formats;
@@ -66,7 +67,7 @@ namespace RombaSharp.Features
// Now rescan the depot itself
DatFile depot = DatFile.Create();
DatFromDir.PopulateFromDir(depot, depotname, asFiles: TreatAsFile.NonArchive);
DatFromDir.PopulateFromDir(depot, depotname, asFiles: TreatAsFile.NonArchive, hashes: Hash.Standard);
depot.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
// Set the base queries to use

View File

@@ -154,20 +154,12 @@ Reset the internal state: reset();";
// Assume there could be multiple
foreach (string input in command.Arguments)
{
DatTools.DatFromDir.PopulateFromDir(datFile, input);
DatTools.DatFromDir.PopulateFromDir(datFile, input, hashes: Hash.Standard);
}
// TODO: We might not want to remove higher order hashes in the future
// TODO: We might not want to remove dates in the future
Remover dfdRemover = new Remover();
dfdRemover.PopulateExclusionsFromList(new List<string>
{
"DatItem.SHA256",
"DatItem.SHA384",
"DatItem.SHA512",
"DatItem.SpamSum",
"DatItem.Date",
});
dfdRemover.PopulateExclusionsFromList(new List<string> { "DatItem.Date" });
dfdRemover.ApplyRemovals(datFile);
break;