From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 50E241FF0F1 for ; Mon, 13 Jul 2026 09:10:20 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id EFF7921376; Mon, 13 Jul 2026 09:10:19 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 13 Jul 2026 09:09:46 +0200 Message-Id: Subject: Re: [PATCH datacenter-manager 10/15] task cache: introduce ArchiveFileWriter From: "Lukas Wagner" To: "Dominik Csapak" , "Lukas Wagner" , X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260702092258.174740-1-l.wagner@proxmox.com> <20260702092258.174740-11-l.wagner@proxmox.com> <06d0190e-34d7-4449-92e8-6bc2c379e3ce@proxmox.com> In-Reply-To: <06d0190e-34d7-4449-92e8-6bc2c379e3ce@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783926571505 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.350 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: VJKNWELF7ASDAZ7CU7GYBDQUMRAPCOPH X-Message-ID-Hash: VJKNWELF7ASDAZ7CU7GYBDQUMRAPCOPH X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri Jul 10, 2026 at 1:36 PM CEST, Dominik Csapak wrote: >> + >> + /// Finalize and drop the internal writer and replace the original >> + /// archive file with the new contents. This method consumes `self`= . >> + /// >> + /// [`ArchiveFileWriter::drop`] also finalizes the writer properly,= but does not >> + /// allow to catch errors. >> + fn finalize_and_replace(mut self) -> Result<(), Error> { >> + self.finalize_impl() >> + } >> +} >> + >> +impl<'a> Drop for ArchiveFileWriter<'a> { >> + fn drop(&mut self) { >> + let _ =3D self.finalize_impl(); >> + } >> +} >> + > isn't this a bit dangerous? > > this will be called whenever the writer is dropped regardless of error > conditions and will rotate/overwrite the files. > > e.g. if any write in between fails, the drop handler will be called and= =20 > overwrite an existing archive with the partially written one? > > or am i missing something here? > You are totally right, this is indeed a bad idea, thanks for bringing it up. I'm using the `finalize_and_replace` method everywhere anyways, so I'd change this to actually discard pending changes in drop, instead of committing them. So it would just attempt to remove the temporary file in `drop` instead of replacing the original. Thanks!