Skip to content

Commit

Permalink
Move DeleteJunkEntries back down to Extract
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-zk committed Dec 27, 2024
1 parent de17a11 commit c2e76e9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Extractor/HashFsExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public class HashFsExtractor : Extractor
/// </summary>
protected Dictionary<ulong, IEntry> junkEntries = [];

private bool hasRemovedJunk;

public HashFsExtractor(string scsPath, bool overwrite) : base(scsPath, overwrite)
{
Reader = HashFsReader.Open(scsPath, ForceEntryTableAtEnd);
Expand All @@ -96,13 +98,13 @@ public HashFsExtractor(string scsPath, bool overwrite) : base(scsPath, overwrite
{
Reader.Salt = Salt.Value;
}

DeleteJunkEntries();
}

/// <inheritdoc/>
public override void Extract(string[] startPaths, string destination)
{
DeleteJunkEntries();

if (startPaths.Length == 1 && startPaths[0] == "/"
&& Reader.EntryExists("/") == EntryType.Directory)
{
Expand Down Expand Up @@ -240,6 +242,9 @@ private void ExtractToDiskInner(string file, string outputPath,

protected void DeleteJunkEntries()
{
if (hasRemovedJunk)
return;

var visitedOffsets = new Dictionary<ulong, IEntry>();
var junk = new Dictionary<ulong, IEntry>();
foreach (var (hash, entry) in Reader.Entries)
Expand All @@ -256,6 +261,8 @@ protected void DeleteJunkEntries()
junkEntries.Add(hash, entry);
duplicate++;
}

hasRemovedJunk = true;
}

public override void PrintContentSummary()
Expand Down

0 comments on commit c2e76e9

Please sign in to comment.