emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f75fec5cacc: Fix uncompressing a .tar.gz archive whose files have


From: Eli Zaretskii
Subject: master f75fec5cacc: Fix uncompressing a .tar.gz archive whose files have no leading dir
Date: Thu, 23 May 2024 05:52:19 -0400 (EDT)

branch: master
commit f75fec5cacce47c9714f10592d75c8fb9c63999d
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix uncompressing a .tar.gz archive whose files have no leading dir
    
    * lisp/dired-aux.el (dired-compress): Handle the case when
    NEW-FILE is not produced in the current directory by uncompressing
    a compressed file.  (Bug#47058)
---
 lisp/dired-aux.el | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 22c6881ae35..d1d5ed9b144 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1522,14 +1522,23 @@ A FMT of \"\" will suppress the messaging."
          ;; Remove any preexisting entry for the name NEW-FILE.
          (ignore-errors (dired-remove-entry new-file))
          (goto-char start)
-         ;; Now replace the current line with an entry for NEW-FILE.
-         ;; But don't remove the current line if either FROM-FILE or
-         ;; NEW-FILE is a directory, because compressing/uncompressing
-          ;; directories doesn't remove the original.
-          (if (or (file-directory-p from-file)
-                  (file-directory-p new-file))
-              (dired-add-entry new-file nil t)
-            (dired-update-file-line new-file))
+         ;; Now replace the current line with an entry for NEW-FILE,
+         ;; if it exists.  But don't remove the current line if
+         ;; either FROM-FILE or NEW-FILE is a directory, because
+         ;; compressing/uncompressing directories doesn't remove the
+         ;; original.  If NEW-FILE doesn't exist, assume that we are
+         ;; out of sync with the current directory, and revert it.
+         ;; This can happen, for example, when unpacking a .tar.gz
+         ;; archive which adds files to the current directory (as
+         ;; opposed to adding them to a directory whose name is
+         ;; NEW-FILE).
+          (if (file-exists-p new-file)
+              (if (or (file-directory-p from-file)
+                      (file-directory-p new-file))
+                  (dired-add-entry new-file nil t)
+                (dired-update-file-line new-file))
+            (dired-fun-in-all-buffers (dired-current-directory)
+                                      nil #'revert-buffer))
           nil)
       (dired-log (concat "Failed to (un)compress " from-file))
       from-file)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]