-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
In macOS I had the very same issue as #65, with org-web-tools-archive-view. Every time I use the function, this message appears,
Extraction of file failed: tar: Option -a is not permitted in mode -x
I could solve the problem by removing the --auto-compress flag and advising the new function instead of the original one.
Maybe this could be applied upstream if you find useful.
(defun org-web-tools-archive-view-mod ()
"Open Zip file archive of web page.
Extracts to a temp directory and opens with
`browse-url-default-browser'. Note: the extracted files are left
on-disk in the temp directory."
(interactive)
(unless (executable-find "unzip")
(error "Can't find unzip command"))
(let* ((attach-dir (org-attach-dir t))
(files (org-attach-file-list attach-dir))
(file (if (= (length files) 1)
(car files)
(completing-read "Open attachment: "
(mapcar #'list files) nil t)))
(extension (file-name-extension file))
(archive-path (expand-file-name file attach-dir))
(temp-dir (make-temp-file "org-web-tools-view-archive-" 'dir)))
(with-temp-buffer
(unless (zerop (pcase extension
;; TODO: If/when we want to support only Emacs 26+, we
;; can use the `rx' matcher instead of `file-name-extension',
;; and easily test for e.g. ".tar.xz".
("zip" (call-process (executable-find "unzip") nil t nil
archive-path "-d" temp-dir))
;; Assume that if it's not a zip file, it's a tar archive
;; (`extension' will be just, e.g. "xz").
(_ (call-process (executable-find "tar") nil t nil
;; "--auto-compress"
"--extract"
"--directory" temp-dir
"--file" archive-path))))
(error "Extraction of file failed: %s" (buffer-string))))
(->> (directory-files temp-dir 'full-path (rx ".html" eos))
(-map #'org-web-tools-archive-view--escape-filename)
(--map (concat "file://" it))
(-map #'browse-url-default-browser))
(message "Files extracted to: %s" temp-dir)))
(advice-add #'org-web-tools-archive-view :override #'org-web-tools-archive-view-mod)Best.
Metadata
Metadata
Assignees
Labels
No labels