mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make DFD code cleaner for future work
This commit is contained in:
@@ -59,6 +59,7 @@ have a current entry in the DAT index.";
|
||||
bool noDb = GetBoolean(features, NoDbValue);
|
||||
bool onlyNeeded = GetBoolean(features, OnlyNeededValue);
|
||||
HashType[] hashes = [HashType.CRC32, HashType.MD5, HashType.SHA1];
|
||||
var dfd = new DatFromDir(hashes, SkipFileType.None, addBlanks: false);
|
||||
|
||||
// First we want to get just all directories from the inputs
|
||||
List<string> onlyDirs = [];
|
||||
@@ -72,8 +73,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, hashes: hashes);
|
||||
DatFromDir.PopulateFromDir(df, dir, asFiles: TreatAsFile.All, hashes: hashes);
|
||||
dfd.PopulateFromDir(df, dir, TreatAsFile.NonArchive);
|
||||
dfd.PopulateFromDir(df, dir, TreatAsFile.All);
|
||||
}
|
||||
|
||||
// Create an empty Dat for files that need to be rebuilt
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace RombaSharp.Features
|
||||
string? source = GetString(features, SourceStringValue);
|
||||
string? outdat = GetString(features, OutStringValue);
|
||||
HashType[] hashes = [HashType.CRC32, HashType.MD5, HashType.SHA1];
|
||||
var dfd = new DatFromDir(hashes, SkipFileType.None, addBlanks: false);
|
||||
|
||||
// Ensure the output directory
|
||||
outdat = outdat.Ensure(create: true);
|
||||
@@ -57,7 +58,7 @@ namespace RombaSharp.Features
|
||||
DatFile datfile = DatFile.Create();
|
||||
datfile.Header.SetFieldValue<string?>(SabreTools.Models.Metadata.Header.NameKey, string.IsNullOrWhiteSpace(name) ? "untitled" : name);
|
||||
datfile.Header.SetFieldValue<string?>(SabreTools.Models.Metadata.Header.DescriptionKey, description);
|
||||
DatFromDir.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive, hashes: hashes);
|
||||
dfd.PopulateFromDir(datfile, source, TreatAsFile.NonArchive);
|
||||
Writer.Write(datfile, outdat!);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ contents of any changed dats.";
|
||||
int workers = GetInt32(features, WorkersInt32Value);
|
||||
string? missingSha1s = GetString(features, MissingSha1sStringValue);
|
||||
HashType[] hashes = [HashType.CRC32, HashType.MD5, HashType.SHA1];
|
||||
var dfd = new DatFromDir(hashes, SkipFileType.None, addBlanks: false);
|
||||
|
||||
// Make sure the db is set
|
||||
if (string.IsNullOrWhiteSpace(_db))
|
||||
@@ -70,7 +71,7 @@ contents of any changed dats.";
|
||||
// First get a list of SHA-1's from the input DATs
|
||||
DatFile datroot = DatFile.Create();
|
||||
datroot.Header.SetFieldValue<string?>(SabreTools.Models.Metadata.Header.TypeKey, "SuperDAT");
|
||||
DatFromDir.PopulateFromDir(datroot, _dats, asFiles: TreatAsFile.NonArchive, hashes: hashes);
|
||||
dfd.PopulateFromDir(datroot, _dats, TreatAsFile.NonArchive);
|
||||
datroot.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
|
||||
|
||||
// Create a List of dat hashes in the database (SHA-1)
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace RombaSharp.Features
|
||||
return false;
|
||||
|
||||
HashType[] hashes = [HashType.CRC32, HashType.MD5, HashType.SHA1];
|
||||
var dfd = new DatFromDir(hashes, SkipFileType.None, addBlanks: false);
|
||||
|
||||
logger.Error("This feature is not yet implemented: rescan-depots");
|
||||
|
||||
@@ -74,7 +75,7 @@ namespace RombaSharp.Features
|
||||
|
||||
// Now rescan the depot itself
|
||||
DatFile depot = DatFile.Create();
|
||||
DatFromDir.PopulateFromDir(depot, depotname, asFiles: TreatAsFile.NonArchive, hashes: hashes);
|
||||
dfd.PopulateFromDir(depot, depotname, TreatAsFile.NonArchive);
|
||||
depot.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
|
||||
|
||||
// Set the base queries to use
|
||||
|
||||
Reference in New Issue
Block a user