From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#55166: 28.1; tar-mode doesn't re-compress when saving remote files Date: Tue, 03 May 2022 14:36:53 +0200 Message-ID: <87h766u716.fsf@gmx.de> References: <87y1zphwly.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22301"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 55166@debbugs.gnu.org, Dan McCarthy To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 03 14:39:04 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlrnz-0005bp-Vq for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 May 2022 14:39:04 +0200 Original-Received: from localhost ([::1]:32994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlrny-0002NC-Of for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 May 2022 08:39:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlrn0-0002Kq-1b for bug-gnu-emacs@gnu.org; Tue, 03 May 2022 08:38:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45027) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlrmz-0002Mw-O8 for bug-gnu-emacs@gnu.org; Tue, 03 May 2022 08:38:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nlrmz-0006ou-Lx for bug-gnu-emacs@gnu.org; Tue, 03 May 2022 08:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 May 2022 12:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55166 X-GNU-PR-Package: emacs Original-Received: via spool by 55166-submit@debbugs.gnu.org id=B55166.165158142426136 (code B ref 55166); Tue, 03 May 2022 12:38:01 +0000 Original-Received: (at 55166) by debbugs.gnu.org; 3 May 2022 12:37:04 +0000 Original-Received: from localhost ([127.0.0.1]:38921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlrm4-0006nT-DV for submit@debbugs.gnu.org; Tue, 03 May 2022 08:37:04 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:49057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nlrm2-0006my-0p for 55166@debbugs.gnu.org; Tue, 03 May 2022 08:37:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1651581415; bh=7zL5Hu4B+GMejhfb3SajOZl1MFpemItkATPgMZJfw3w=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=BKKPfakD8nuueIYmNJYE5twBAN6C+JzIv8JAE1PmNRbMaUeIKSssf6mJi1qEgAAIg eTEhhedjYuery7nrq0waN4rt9PUFxOeGFSa34iIkmdnW+a67ea3E+9tmruR8yQ7LFI +7I5VLrJxecD6ppuJwhy1fu+kf3rt/nOboSA86pI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.119.214]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M4Jqb-1nlaek108P-000Ntr; Tue, 03 May 2022 14:36:55 +0200 In-Reply-To: <87y1zphwly.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 28 Apr 2022 20:49:13 +0200") X-Provags-ID: V03:K1:D50Cq3JvEF+6wYCQdtacjWAA82FG12RvOIPabVfM0/vwt6Hibva 70pdGl5LSIpgzH1hqK0AvCoASPG8+8IrtJhG1k6DVHFjvEd3QWdMnP2tIYWevLIENNmoDZV cNbm0NMKGRw0q3m3YG3q9uxYwZhrmu2lUzeiidY0iI4SJ88ryAHISkAKb2RyYBnR5T5nG6W vUdI5PMN8mqF9/GGMpj1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:+tu2gyUg//o=:+cNtGhO9Mk9y5mzphodacp Xq94WhtQQdsNhj1I840gx6STHL0+8HcSyUyKGNTJKbZXFBy6MxyAEeFwXby6uQWNwo0kZVEbx QxrFlVVs2G+WIH+Z3PW32uBKNS9CYnXfWu0NX6pmWJgMFMXu5jC/9nV8Z05Ow9EZxfIKIicDO yxyW4qV0y7TgE74ETPAJSmzaY0kgq2IlMIves2E2obYG43lWSzgAzSJDFoUY/oqgaeMPZZgms NE2ELw/YI+KAeNoxCV26Zh0sIKRg3TuK4dwRN0xOq3SCiiOrc44lmW4Z0XBd8dH0rtAZ7xPWZ TGAC1Eof8aHOsOF+75rm5i632YXVAVtrhCiJ9VrlmKYhKMUYPIuDDUFb6ix7Vb+OG56DGcf+4 l4czmtmKjCBlrXliw/bHtXH4E8RLLWNV0X6FG9187ht34CgXL7XmQJdiOfvM+/NjzgCAJtLhP XZSFHY/UCyGJnPoVeEm32oB2qrCq2ZkydnTVeeT2SL/pX1c3GIDS/Fi2crHK/bJcm2RZPlNlC itXCalnblGL581f+jIVQqEGu7NL0Wy6h3VHMR9iMgnJXRs7eD5MekZP6t1WPZnxtq6CtQe5U4 HZHMcYjeUSyW9Kq4WA1jbiEesP0Io0BFGsP2enNgBsr0B8B23qxKZndE4xUi0V389hyct0kY0 KUJrZoGRLNavUNe9L4EckNOGth/CQeJezbUOKXfQPeM/r88+fSCYGZq6iHkXYmwiBS5jfRp7C L9nRvJA42jh8FTnfSLciO4M5Cyu5PdGBPUl1XiUltAewFtxJ77rLhcdJSq0zp9frMGatna3W X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231323 Archived-At: Lars Ingebrigtsen writes: Hi, >> dan@solstice:/tmp$ touch a b c >> dan@solstice:/tmp$ tar cf test.tar a b c >> dan@solstice:/tmp$ bzip2 -z test.tar >> dan@solstice:/tmp$ file test.tar.bz2 >> test.tar.bz2: bzip2 compressed data, block size =3D 900k >> >> If you visit that remote file and save it, the result will have the .bz= 2 >> extension but won't actually be compressed: >> >> dan@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 archi= ves. > > 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 =2D-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) =2D-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.