Explicitly handle password-protected archives rather than repeatedly throwing exceptions (#47)

* Explicitly handle password-protected archives rather than repeatedly throwing exceptions

* Fix logic error

* Continues

* Remove bool
This commit is contained in:
HeroponRikiBestest
2025-12-02 07:38:11 -07:00
committed by GitHub
parent 59eddb7129
commit 0b54350d59
3 changed files with 58 additions and 8 deletions

View File

@@ -58,6 +58,14 @@ namespace SabreTools.Serialization.Wrappers
// If the entry is partial due to an incomplete multi-part archive, skip it
if (!entry.IsComplete)
continue;
// If the entry is password-protected, skip it
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine($"File {entry.Key} in zip is password-protected!");
continue;
}
// Ensure directory separators are consistent
string filename = entry.Key;

View File

@@ -74,12 +74,25 @@ namespace SabreTools.Serialization.Wrappers
continue;
if (firstFile)
firstFile = false;
else
{
isSolid = entry.IsSolid;
break;
firstFile = false;
continue;
}
if (entry.IsSolid)
{
// If the RAR is solid and the first entry is password-protected, you won't be able to
// extract the rest of the entries anyway, so just return early.
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine("RAR is password-protected!");
return false;
}
isSolid = true;
}
break;
}
catch (Exception ex)
{
@@ -215,6 +228,14 @@ namespace SabreTools.Serialization.Wrappers
// If we have a partial entry due to an incomplete multi-part archive, skip it
if (!entry.IsComplete)
continue;
// If the entry is password-protected, skip it
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine($"File {entry.Key} in RAR is password-protected!");
continue;
}
// Ensure directory separators are consistent
string filename = entry.Key;

View File

@@ -73,12 +73,25 @@ namespace SabreTools.Serialization.Wrappers
continue;
if (firstFile)
firstFile = false;
else
{
isSolid = entry.IsSolid;
break;
firstFile = false;
continue;
}
if (entry.IsSolid)
{
// If the 7z is solid and the first entry is password-protected, you won't be able to
// extract the rest of the entries anyway, so just return early.
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine("7z is password-protected!");
return false;
}
isSolid = true;
}
break;
}
catch (Exception ex)
{
@@ -183,6 +196,14 @@ namespace SabreTools.Serialization.Wrappers
// If we have a partial entry due to an incomplete multi-part archive, skip it
if (!entry.IsComplete)
continue;
// If the entry is password-protected, skip it
if (entry.IsEncrypted)
{
if (includeDebug) Console.WriteLine($"File {entry.Key} in 7z is password-protected!");
continue;
}
// Ensure directory separators are consistent
string filename = entry.Key;