From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71074: 29.3; When doing a backup, the file is missing during interactive questions Date: Tue, 21 May 2024 15:12:05 +0300 Message-ID: <86msoj8iui.fsf@gnu.org> References: <20240520010748.GB323381@qaa.vinc17.org> <86pltgaff3.fsf@gnu.org> <20240521084416.GH2665@qaa.vinc17.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40246"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71074@debbugs.gnu.org To: Vincent Lefevre Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 21 14:13:33 2024 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 1s9ON2-000AII-Ib for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 May 2024 14:13:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9OMY-0004KW-Ea; Tue, 21 May 2024 08:13:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9OMV-0004Jy-KY for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 08:13:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9OMT-0006ty-Mp for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 08:12:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s9OMY-000548-JD for bug-gnu-emacs@gnu.org; Tue, 21 May 2024 08:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 May 2024 12:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71074 X-GNU-PR-Package: emacs Original-Received: via spool by 71074-submit@debbugs.gnu.org id=B71074.171629354819466 (code B ref 71074); Tue, 21 May 2024 12:13:02 +0000 Original-Received: (at 71074) by debbugs.gnu.org; 21 May 2024 12:12:28 +0000 Original-Received: from localhost ([127.0.0.1]:48838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9OLx-00053u-Fw for submit@debbugs.gnu.org; Tue, 21 May 2024 08:12:27 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9OLs-00053o-9h for 71074@debbugs.gnu.org; Tue, 21 May 2024 08:12:24 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9OLh-0006mR-2o; Tue, 21 May 2024 08:12:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=FxDGTJsS2amh6cLDVrgx3F4xeO4hS32g2M84hgE9AHI=; b=r9WLPkHBzyit cgUbTyCMkKHKF5eKyomwRnu3xYBWEjNKfIZAuyYsQQ9KsqA16P+pU+LQ+FXilmn2sg80aBGO/iX5k E1uHpOleKPNHLvqHrrMyPsqXloIh7NZ6SQinSn53gFrQxkHaQvmYaaV5LlUxJh5GoBceIu2eafR/0 8362Kxhzi+POhE3OvCwkfFSQTFYVzFm02Z4dDDCb2QNt/BGMdjc9Ze7mcojJzBhqQrxcsgZsTky2K ww/ZLVyPeMZgSrAeixCTTH+BgksjZt/QYipT6I1DQeZnwwsX2r5WuvUR2rQ909NivKVnVcQauD2rg 8Rj/ryxQ9sUc1PYjQ556Ng==; In-Reply-To: <20240521084416.GH2665@qaa.vinc17.org> (message from Vincent Lefevre on Tue, 21 May 2024 10:44:16 +0200) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285530 Archived-At: > Date: Tue, 21 May 2024 10:44:16 +0200 > From: Vincent Lefevre > Cc: 71074@debbugs.gnu.org > > On 2024-05-20 14:30:56 +0300, Eli Zaretskii wrote: > > Does it help to customize the variable backup-by-copying to a non-nil > > value? > > Yes, but note that a useless backup is done because the file will > not necessarily be saved (if the save operation is canceled via > an interactive question or due to Debian bug 1071372). Sure, but if the danger is to lose the file due to some calamity, a useless backup is a very minor disadvantage, don't you agree? > Whether renaming or copying, the backup should be done just before > actually saving. We already do that. However, backup+save is not an atomic operation, and as long as it is not atomic, there's always a window of opportunity for some catastrophe, like a system crash or Emacs being killed, to happen in-between. Moreover, Emacs being Emacs, with its high degree of customization, some feature can customize either backup or save (or both) in a way that makes the above-mentioned window very wide. That's what happened in the case you reported: epa-file overrides write-contents, the Emacs primitive that actually writes the buffer to a file, with its own version, and that's why you get that prompt about untrusted key. We cannot avoid such situations, because if we disallow customizations like that, Emacs will no longer be Emacs. In fact, you yourself use a similar feature, when you define find-backup-file-name to force all the backup files to go to a specific directory. Such a function could in theory do anything it wants, including prompting you and whatnot, thus prolonging the window between the backup and the save. So I don't see how we could significantly change this situation without losing very useful features, and therefore I think backup-by-copying is the best solution we can provide in such cases.