From: Visuwesh <visuweshm@gmail.com>
To: 56603@debbugs.gnu.org
Subject: bug#56603: [PATCH] Ensure that directories exist when copying files from archive
Date: Sat, 16 Jul 2022 20:50:38 +0530 [thread overview]
Message-ID: <87k08d13uh.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]
Tags: patch
If a zip file is of the following contents,
a/some-text.txt
a/b/some-other.txt
and you mark all files and extract them to the directory /tmp/test/, the current copy
command bugs out since `write-to-region' complains about /tmp/test/a/ and
/tmp/test/a/b/ not existing.
If you tried to extract a single file a/some-text.txt after answer /tmp/
to the prompt, the C command fails due to the above reason.
This patch creates the relevant directories if they don't exist. But
perhaps the patch should be more robust? I.e., if /tmp/test/a was a
file, then it should error?
In GNU Emacs 29.0.50 (build 21, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
of 2022-07-16 built on astatine
Repository revision: 9a5b52dace4cb0fe6b99205911d9b2f2487a4a83
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid
Configured using:
'configure --with-sound=alsa --with-x-toolkit=lucid --with-json
--without-xaw3d --without-gconf --without-libsystemd --without-cairo'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Ensure-that-directories-exist-when-copying-files-fro.patch --]
[-- Type: text/patch, Size: 1548 bytes --]
From 0166179e60644475abb878ecec86c8847871eab6 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Sat, 16 Jul 2022 20:44:50 +0530
Subject: [PATCH] Ensure that directories exist when copying files from archive
* lisp/arc-mode.el (archive-copy-file): If the directory the file is
being extracted to does not exist, then create it.
---
lisp/arc-mode.el | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index c52f2a4432..e5aadccc87 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -1073,13 +1073,16 @@ archive-copy-file
(user-error "Can't copy a list of files to a single file"))
(save-excursion
(dolist (file files)
- (let ((write-to (if (file-directory-p new-name)
- (expand-file-name file new-name)
- new-name)))
+ (let* ((write-to (if (file-directory-p new-name)
+ (expand-file-name file new-name)
+ new-name))
+ (write-to-dir (file-name-directory write-to)))
(when (and (file-exists-p write-to)
(not (yes-or-no-p (format "%s already exists; overwrite? "
write-to))))
(user-error "Not overwriting %s" write-to))
+ (unless (file-directory-p write-to-dir)
+ (make-directory write-to-dir t))
(archive-goto-file file)
(let* ((descr (archive-get-descr))
(archive (buffer-file-name))
--
2.35.1
next reply other threads:[~2022-07-16 15:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-16 15:20 Visuwesh [this message]
2022-07-17 9:23 ` bug#56603: [PATCH] Ensure that directories exist when copying files from archive Lars Ingebrigtsen
2022-07-17 9:58 ` Visuwesh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k08d13uh.fsf@gmail.com \
--to=visuweshm@gmail.com \
--cc=56603@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).