mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
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:
committed by
GitHub
parent
59eddb7129
commit
0b54350d59
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user