From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#10347: 24.0.50; archive-mode includes warning messages from unzip in the content of extracted files Date: Sun, 25 Dec 2011 23:28:52 +0200 Organization: JURTA Message-ID: <877h1kwdd3.fsf@mail.jurta.org> References: <874nwsbcc4.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1324850145 23784 80.91.229.12 (25 Dec 2011 21:55:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 25 Dec 2011 21:55:45 +0000 (UTC) Cc: 10347@debbugs.gnu.org To: Daniel Brooks Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 25 22:55:40 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rew2d-000217-39 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Dec 2011 22:55:39 +0100 Original-Received: from localhost ([::1]:52865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rew2c-0002l2-FU for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Dec 2011 16:55:38 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:43736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rew2Z-0002kv-KO for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:55:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rew2Y-0000Dv-CG for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:55:35 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rew2Y-0000Dg-6d for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:55:34 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rew4w-0005vW-Rh for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Dec 2011 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10347 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10347-submit@debbugs.gnu.org id=B10347.132485026222743 (code B ref 10347); Sun, 25 Dec 2011 21:58:02 +0000 Original-Received: (at 10347) by debbugs.gnu.org; 25 Dec 2011 21:57:42 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rew4b-0005uh-QI for submit@debbugs.gnu.org; Sun, 25 Dec 2011 16:57:42 -0500 Original-Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rew4Y-0005uQ-M1 for 10347@debbugs.gnu.org; Sun, 25 Dec 2011 16:57:39 -0500 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id 5EB30684091; Sun, 25 Dec 2011 13:55:09 -0800 (PST) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id E65B5451C686; Sun, 25 Dec 2011 13:54:32 -0800 (PST) In-Reply-To: (Daniel Brooks's message of "Thu, 22 Dec 2011 14:23:30 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 25 Dec 2011 16:58:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55191 Archived-At: Actually, `archive-rar-extract' has exactly the same problem. When `unrar-free' can't extract some files from RAR archives, it displays a confusing message: Removing old name: no such file or directory, /tmp/arc-rar1971TAO/file.txt It needs the same treatment as 7z and zip. But the difference is that `unrar-free' outputs only to stdout, not to stderr. And when the operation is successful, it outputs long text with the known fixed message "All OK" indicating success. So we should check for this message, and not display a message on success. Here is a patch that adds `archive-extract-by-file' for RAR archives: === modified file 'lisp/arc-mode.el' --- lisp/arc-mode.el 2011-12-15 07:24:10 +0000 +++ lisp/arc-mode.el 2011-12-25 21:27:01 +0000 @@ -1996,23 +2008,41 @@ (defun archive-rar-summarize (&optional (insert sep (make-string maxname ?-) "\n") (apply 'vector files)))) +(defun archive-extract-by-file (archive name command &optional stdout-test) + (let ((dest (make-temp-file "arc-dir" 'dir)) + (stdout-file (make-temp-file "arc-stdout"))) + (unwind-protect + (prog1 + (apply 'call-process + (car command) + nil + `(:file ,stdout-file) + nil + (append (cdr command) (list archive name dest))) + (with-temp-buffer + (insert-file-contents stdout-file) + (when (if (stringp stdout-test) + (not (search-forward stdout-test nil t)) + (> (buffer-size) 0)) + (message "%s" (buffer-string)))) + (if (file-exists-p (expand-file-name name dest)) + (insert-file-contents-literally (expand-file-name name dest)))) + (if (file-exists-p stdout-file) + (delete-file stdout-file)) + (if (file-exists-p (expand-file-name name dest)) + (delete-file (expand-file-name name dest))) + (while (file-name-directory name) + (setq name (directory-file-name (file-name-directory name))) + (delete-directory (expand-file-name name dest))) + (delete-directory dest)))) + (defun archive-rar-extract (archive name) ;; unrar-free seems to have no way to extract to stdout or even to a file. (if (file-name-absolute-p name) ;; The code below assumes the name is relative and may do undesirable ;; things otherwise. (error "Can't extract files with non-relative names") - (let ((dest (make-temp-file "arc-rar" 'dir))) - (unwind-protect - (progn - (call-process "unrar-free" nil nil nil - "--extract" archive name dest) - (insert-file-contents-literally (expand-file-name name dest))) - (delete-file (expand-file-name name dest)) - (while (file-name-directory name) - (setq name (directory-file-name (file-name-directory name))) - (delete-directory (expand-file-name name dest))) - (delete-directory dest))))) + (archive-extract-by-file archive name '("unrar-free" "--extract") "All OK"))) ;;; Section: Rar self-extracting .exe archives.