mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-15 04:39:07 +00:00
limit the usage of slow ReaderFactory into ".tar.xx" formats
This commit is contained in:
@@ -79,21 +79,10 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
{
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
// https://github.com/adamhathcock/sharpcompress/blob/master/FORMATS.md says:
|
||||
// The 7Zip format doesn't allow for reading as a forward-only stream so 7Zip is only supported through the Archive API
|
||||
if (Path.GetExtension(path).ToLower() == ".7z")
|
||||
{
|
||||
var archive = ArchiveFactory.Open(stream);
|
||||
// ReaderFactory is slow... so limit its usage
|
||||
string[] useReader = {".tar.gz", ".tgz", ".tar.bz2", ".tar.lz", ".tar.xz"};
|
||||
|
||||
_type = archive.Type.ToString();
|
||||
|
||||
var root = new ArchiveFileEntry(Path.GetFileName(path), true);
|
||||
_fileEntries.Add("", root);
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
ProcessByLevel(entry);
|
||||
}
|
||||
else
|
||||
if (useReader.Any(i => path.EndsWith(i)))
|
||||
{
|
||||
var reader = ReaderFactory.Open(stream);
|
||||
|
||||
@@ -105,6 +94,18 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
while (reader.MoveToNextEntry())
|
||||
ProcessByLevel(reader.Entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
var archive = ArchiveFactory.Open(stream);
|
||||
|
||||
_type = archive.Type.ToString();
|
||||
|
||||
var root = new ArchiveFileEntry(Path.GetFileName(path), true);
|
||||
_fileEntries.Add("", root);
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
ProcessByLevel(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
case ".rar":
|
||||
case ".zip":
|
||||
case ".tar":
|
||||
case ".tgz":
|
||||
case ".gz":
|
||||
case ".bz2":
|
||||
case ".lz":
|
||||
@@ -39,7 +40,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
context.PreferredSize = new Size {Width = 800, Height = 600};
|
||||
context.PreferredSize = new Size {Width = 800, Height = 400};
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
|
Reference in New Issue
Block a user