Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ProtectionScan/Features/MainFeature.cs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix needed for instances where a scanned archive has protections, and then the directory that archive is extracted to also has directorycheck protections.

Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,28 @@ private static void InsertNode(Dictionary<string, object> nestedDictionary,
}

// If the "leaf" dictionary has been reached, add the file and its protections.
current.Add(pathParts[^1], protections);
if (current.ContainsKey(pathParts[^1]))
{
var array1 = (string[])current[pathParts[^1]];
var array2 = protections;

string[] result = new string[array1.Length + array2.Length];
for (int i = 0; i < array1.Length; i++)
{
result[i] = array1[i];
}

for (int i = 0; i < array2.Length; i++)
{
result[array1.Length + i] = array2[i];
}

current[pathParts[^1]] = result;
}
else
{
current.Add(pathParts[^1], protections);
}
}
#endif
}
Expand Down