Skip to content
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,25 @@ protected async Task DecompressArchiveHereAsync(bool smart = false)
if (zipFile is null)
return true;

return zipFile.ArchiveFileData.Select(file =>
static string? GetFirstMeaningfulSegment(string? fileName)
{
var pathCharIndex = file.FileName.IndexOfAny(['/', '\\']);
if (pathCharIndex == -1)
return file.FileName;
else
return file.FileName.Substring(0, pathCharIndex);
})
.Distinct().Count() > 1;
if (string.IsNullOrEmpty(fileName))
return null;

var parts = fileName.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries);
foreach (var part in parts.Where(part => part is not "." and not ".."))
return part;

return null;
}

var topLevelEntries = zipFile.ArchiveFileData
.Select(file => GetFirstMeaningfulSegment(file.FileName))
.Where(x => !string.IsNullOrEmpty(x))
.Distinct()
.Count();

return topLevelEntries > 1;
});

if (smart && currentFolder is not null && isMultipleItems)
Expand Down
Loading