From ef5afda76f101d4ba65699b05767b02c6e7e4629 Mon Sep 17 00:00:00 2001 From: Han Cen Date: Wed, 1 Jun 2022 17:29:13 +0800 Subject: [PATCH] Add support for `.tgz` files Closes #17 --- QLPlugin/Info.plist | 1 + QLPlugin/Utils/File.swift | 2 +- QLPlugin/Views/PreviewVCFactory.swift | 2 +- QLPlugin/Views/Previews/TARPreview.swift | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/QLPlugin/Info.plist b/QLPlugin/Info.plist index 78b9b28..1f16a43 100644 --- a/QLPlugin/Info.plist +++ b/QLPlugin/Info.plist @@ -41,6 +41,7 @@ com.sun.web-application-archive dyn.ah62d4rv4ge80n2pw org.gnu.gnu-zip-archive + org.gnu.gnu-zip-tar-archive public.tar-archive public.zip-archive diff --git a/QLPlugin/Utils/File.swift b/QLPlugin/Utils/File.swift index 4851822..6ebbf4e 100644 --- a/QLPlugin/Utils/File.swift +++ b/QLPlugin/Utils/File.swift @@ -27,7 +27,7 @@ extension FileError: LocalizedError { /// Utility class for reading the content and metadata of the corresponding file. class File { - let archiveExtensions = ["tar", "tar.gz", "zip"] + let archiveExtensions = ["tar", "tar.gz", "tgz", "zip"] let fileManager = FileManager.default var attributes: [FileAttributeKey: Any] diff --git a/QLPlugin/Views/PreviewVCFactory.swift b/QLPlugin/Views/PreviewVCFactory.swift index 5382f3d..a3a6624 100644 --- a/QLPlugin/Views/PreviewVCFactory.swift +++ b/QLPlugin/Views/PreviewVCFactory.swift @@ -12,7 +12,7 @@ class PreviewVCFactory { return MarkdownPreview.self case "ipynb": return JupyterPreview.self - case "tar": + case "tar", "tgz": return TARPreview.self case "tab", "tsv": return TSVPreview.self diff --git a/QLPlugin/Views/Previews/TARPreview.swift b/QLPlugin/Views/Previews/TARPreview.swift index 205c44c..71a349a 100644 --- a/QLPlugin/Views/Previews/TARPreview.swift +++ b/QLPlugin/Views/Previews/TARPreview.swift @@ -140,7 +140,7 @@ class TARPreview: Preview { } func createPreviewVC(file: File) throws -> PreviewVC { - let isGzipped = file.path.hasSuffix(".tar.gz") + let isGzipped = file.path.hasSuffix(".tar.gz") || file.path.hasSuffix(".tgz") // Parse TAR contents let filesOutput = try runTARFilesCommand(filePath: file.path)