GNU bug report logs -
#55166
28.1; tar-mode doesn't re-compress when saving remote files
Previous Next
Reported by: Dan McCarthy <daniel.c.mccarthy <at> gmail.com>
Date: Thu, 28 Apr 2022 15:44:02 UTC
Severity: normal
Found in version 28.1
Fixed in version 29.1
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 55166 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
It works perfectly. Thanks a lot!
On Tue, May 3, 2022 at 8:36 AM Michael Albinus <michael.albinus <at> gmx.de>
wrote:
> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
> Hi,
>
> >> dan <at> solstice:/tmp$ touch a b c
> >> dan <at> solstice:/tmp$ tar cf test.tar a b c
> >> dan <at> solstice:/tmp$ bzip2 -z test.tar
> >> dan <at> solstice:/tmp$ file test.tar.bz2
> >> test.tar.bz2: bzip2 compressed data, block size = 900k
> >>
> >> If you visit that remote file and save it, the result will have the .bz2
> >> extension but won't actually be compressed:
> >>
> >> dan <at> solstice:/tmp$ file test.tar.bz2
> >> test.tar.bz2: POSIX tar archive (GNU)
> >>
> >> This doesn't happen with compressed remote files which aren't tar
> archives.
> >
> > I can reproduce this problem with Emacs 29, too. (And if I edit the
> > file locally instead of via tramp, the tar file is saved compressed, so
> > it seems to be tramp-related.)
>
> Well, the problem seems to exist since Emacs 27, likely due to some
> subtle changes in basic-save-buffer-1 or basic-save-buffer-2. I haven't
> poked further there, because it looks like saving the buffer with this
> constellation happened twice in Emacs 26, which looks not optimal.
>
> The problem is an exotic feature of write-region, which first looks for
> a file name handler in FILENAME, and if there isn't one, it checks
> VISIT.
>
> write-region of the compressed remote tar file in the scenario above is
> called like
>
> --8<---------------cut here---------------start------------->8---
> ...
> tramp-file-name-handler(write-region nil nil
> "/ssh:detlef:/tmp/tmpfSxlA9" nil "/ssh:detlef:/tmp/test.tar.bz2"
> "/ssh:detlef:/tmp/test.tar.bz2" nil)
> write-region(nil nil "/ssh:detlef:/tmp/tmpfSxlA9" nil
> "/ssh:detlef:/tmp/test.tar.bz2" "/ssh:detlef:/tmp/test.tar.bz2")
> basic-save-buffer-2()
> basic-save-buffer-1()
> basic-save-buffer(t)
> save-buffer(1)
> funcall-interactively(save-buffer 1)
> call-interactively(save-buffer nil nil)
> command-execute(save-buffer)
> --8<---------------cut here---------------end--------------->8---
>
> That is, a remote temporary file ("/ssh:detlef:/tmp/tmpfSxlA9") is
> written, and the magic extension of the remote VISIT argument
> "/ssh:detlef:/tmp/test.tar.bz2" is ignored.
>
> When FILENAME is a local temporary file, the handler for VISIT
> (jka-compr-handler) is triggered. That's the second test Lars has applied.
>
> I've pushed a fix to master, which shall fix this. Dan, could you pls
> check?
>
> In parallel I'll try to write a test case for this problem. But that's
> unrelated to closing this bug.
>
> Best regards, Michael.
>
[Message part 2 (text/html, inline)]
This bug report was last modified 3 years and 21 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.