From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 22 14:23:39 2022 Received: (at submit) by debbugs.gnu.org; 22 Oct 2022 18:23:39 +0000 Received: from localhost ([127.0.0.1]:42302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omJ9j-0008NS-R8 for submit@debbugs.gnu.org; Sat, 22 Oct 2022 14:23:39 -0400 Received: from lists.gnu.org ([209.51.188.17]:41446) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omJ9h-0008NK-86 for submit@debbugs.gnu.org; Sat, 22 Oct 2022 14:23:34 -0400 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 1omJ9e-0005DK-CI for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 14:23:33 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omJ9c-00079k-Ir for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 14:23:30 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 128so5331610pga.1 for ; Sat, 22 Oct 2022 11:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=CbXzF5GzkU64UsPtErXfCT896ZNdEIMmqztWpSq3H8o=; b=eozofrFARH12uqKresZybJpI1IqWg1UmiQ7uBqSNmY7otgKAd92KY61UJ2uNzSFmVO o0BaM9dW4aNDvhRryHv7feOXNaua7KvAvLb6a4oT3F/MCs33MYsLm3bWMfQPGiKaWRzJ nbcFco5iYJef0CZPkjPM0OoeXgJMPaAI2v5UUKH8XSTIVT7mHHzAV9Sl2nH1lw9CEmTr yHemw1eIvWgl6ClwKiS4rrZA0hGCvBj7B7ooZtFoxt3qkGXJN5OWxnbRIp0UbwwVuVMz H7t9LJ595eS+CIYg4FTSd5EmoUNEvyWZfvTWVDj8yU7eFRTjgLCt9wW4T3B9f6CSEIw6 hVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CbXzF5GzkU64UsPtErXfCT896ZNdEIMmqztWpSq3H8o=; b=ysRL5UbYu+Do9xwahaDm/bgKuZH+Qplvlsbc4pcjdxhx5WIeYnGqExrzt3yDuY25Nw n1UcC+BdrHBXL7FisRWCLnYzIXqdsF6cttrADphRfW/58t+FWNWokcO6Kunp8GbZiGap JHbhvDCB9yv5yjQklOJubtaAszKB8+j2Tb4LmYznpRZLHPzey/PCv5lF8x/a3zu5TBVa YFAquF6SwxXQJ3jWM61tImC0vU/aiueYnbZmjG8WE4WR3po8XF1ZiB/NcGeG7+oQ4SMv BeRpV7vwGim9GqpBxUQY71MA3n5ZcIhRleqaVMvGWVdlw9LTkTo/C+GAGsphsB4bM+SW QGxQ== X-Gm-Message-State: ACrzQf0oJcHs1MCAt4hPK4WjzlKqaI9iW9BSwaHwLCz7mM5O9TLDAhb5 UOS16S2IqKPMrr57BDtNF+JzayNZkBKogOjtHb7WrrxbZhHZ6g== X-Google-Smtp-Source: AMsMyM4C8zhCc44d1xDw6eUbYidqlur8HitN+xl7VZN/yeyb6paXzKSdJurFlQVQhomj3M3/AW2N1kp+J4wsfDpDz90= X-Received: by 2002:a05:6a00:3249:b0:565:fc2c:ad79 with SMTP id bn9-20020a056a00324900b00565fc2cad79mr25279985pfb.72.1666463006518; Sat, 22 Oct 2022 11:23:26 -0700 (PDT) MIME-Version: 1.0 From: Gustavo Barros Date: Sat, 22 Oct 2022 15:23:15 -0300 Message-ID: Subject: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=gtvbrs@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HK_RANDOM_ENVFROM=0.824, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi All, If one enables `delete-by-moving-to-trash' and tries to delete a directory with the same name twice from dired, dired won't let one do so, resulting in "file-already-exists: File exists: " error instead. Start with `emacs -Q'. Set: (setq delete-by-moving-to-trash t) Open dired at "/tmp/" (or some other place of your choosing). Clone the org repository there with `M-& git clone https://git.savannah.gnu.org/git/emacs/org-mode.git RET' (a comment on why this below), refresh with `g', navigate to the corresponding directory, and trash it with `D', confirm. The operation succeeds. Now, repeat it. Clone the repository and delete the directory again. I get here "file-already-exists: File exists: /home//.local/share/Trash/files/org-moderiQJ08", and the directory is not trashed. Of course, this has nothing to do with Org. But I've tried to create a simple file with `touch' or an empty directory with `mkdir' and the issue does not arise then. And I haven't figured out what is the difference in the `org-mode' directory which triggers the problem, it just happens to be the last failing case of an issue which happens occasionally here. Best regards, Gustavo. In GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2022-09-12 built on gusbrs-laptop Windowing system distributor 'The X.Org Foundation', version 11.0.12013000 System Description: Linux Mint 20.3 Configured using: 'configure --with-mailutils --with-xwidgets --with-native-compilation --without-compress-install' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM XWIDGETS GTK3 ZLIB Important settings: value of $LC_MONETARY: pt_BR.UTF-8 value of $LC_NUMERIC: pt_BR.UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Messages Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils shell pcomplete comint ansi-color ring dired-aux dired dired-loaddefs time-date subr-x cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads xwidget-internal dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 94422 7608) (symbols 48 7290 0) (strings 32 22714 1404) (string-bytes 1 765786) (vectors 16 15111) (vector-slots 8 314769 11896) (floats 8 27 42) (intervals 56 1346 103) (buffers 992 13)) From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 12:09:34 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 16:09:34 +0000 Received: from localhost ([127.0.0.1]:59054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo5Rl-0007cf-Ui for submit@debbugs.gnu.org; Thu, 27 Oct 2022 12:09:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo5Rk-0007cO-2z for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 12:09:32 -0400 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 1oo5Re-0004mQ-SW; Thu, 27 Oct 2022 12:09:26 -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=9w/BRfjdaKNAW/yBHnKIY4XnztM97ptnKy7E/RCRnbU=; b=ini5/SOegjSp 7lzmTDPwbYVgQw0nWXyS+hxwHEDRx3V8cNbkVrBYBK7XjbTrXEXTckGKGtXT4qpeGhDdk6IcaOy1p TMdJB2rSOlUzXOK76IY8UjKuHupSVt5K1yYrCG9TKbjIa9b5MKGhdeOA+9b8HFObqWbev4IX3fvg6 c0anmM5X89l42i1lP9BZ2s5QQoD+bzygUHvTWTp8Opp2F9CHkpGvFl0aUtqIjaGMf/M6CpJmvFYlA R7E3mNhqqfBZCUCE2zwcaTHRsG4nIqoTl6OhechMNHwePn8i7WfpTIRlJXmLy9jyGQa1IrQugQvJc x9Ctf3BKLdJC3RyNqRDk9A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo5Rc-0005xj-P2; Thu, 27 Oct 2022 12:09:25 -0400 Date: Thu, 27 Oct 2022 19:09:17 +0300 Message-Id: <83r0ytl042.fsf@gnu.org> From: Eli Zaretskii To: Gustavo Barros In-Reply-To: (message from Gustavo Barros on Sat, 22 Oct 2022 15:23:15 -0300) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustavo Barros > Date: Sat, 22 Oct 2022 15:23:15 -0300 > > If one enables `delete-by-moving-to-trash' and tries to delete a > directory with the same name twice from dired, dired won't let one do > so, resulting in "file-already-exists: File exists: " error > instead. > > Start with `emacs -Q'. Set: > > (setq delete-by-moving-to-trash t) > > Open dired at "/tmp/" (or some other place of your choosing). Clone > the org repository there with `M-& git clone > https://git.savannah.gnu.org/git/emacs/org-mode.git RET' (a comment on > why this below), refresh with `g', navigate to the corresponding > directory, and trash it with `D', confirm. The operation succeeds. > > Now, repeat it. Clone the repository and delete the directory again. I > get here "file-already-exists: File exists: > /home//.local/share/Trash/files/org-moderiQJ08", and the > directory is not trashed. > > Of course, this has nothing to do with Org. But I've tried to create > a simple file with `touch' or an empty directory with `mkdir' and the > issue does not arise then. And I haven't figured out what is the > difference in the `org-mode' directory which triggers the problem, it > just happens to be the last failing case of an issue which happens > occasionally here. Could you please set debug-on-error t, repeat the experiment, and post the Lisp backtrace from the error? Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 13:07:41 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 17:07:41 +0000 Received: from localhost ([127.0.0.1]:59175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo6M0-0002w5-Sc for submit@debbugs.gnu.org; Thu, 27 Oct 2022 13:07:41 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:38702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo6Ly-0002vq-RA for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 13:07:39 -0400 Received: by mail-pg1-f179.google.com with SMTP id 20so2107940pgc.5 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 10:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wYsH7eL/jyB++nu3q5pMGnx92tHBGhQlNL5j2qM0guU=; b=aDyPO7Adb8/EQgJr93qzr4JwmHsy95Evq6iNMZ9F1Gg1SQtcCviaabHjPZkw8HOln5 NZbAF0zXf5DOzSalQW7I1mZcOkq9Lx4ATBcVasG8ZVdcpoW+s07zRJ17RcGFmCf1uUaX F6exxJc18TMSXSDBW8XdGs+ZUjkkoKWCniPpWrjzSYylSl0MDEn7K+wall0CS38noDRA pfKU052635ctwohSa3XvPMK9jDJL5F4av9ba4x4Cjmuwe+XZYQh1tE7WV58YmPAfEq8A /XPUWdS9GVe7Q03iLfHo7qIeS6NNje0HD6avIVymD5Bb1SlHjpV2aBEnuz5cqTKVmLzJ hOSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wYsH7eL/jyB++nu3q5pMGnx92tHBGhQlNL5j2qM0guU=; b=hzi7FMSQUuwSuzMOyZC2lFDX/OLuUqC7D3Xg+0UAmQ0Y6NZ/b3BjA/0xlVT4MZL8Gc 8SXe/4Z30zEC169qfHum/q4OUyuHgIWbu3tLLNz+sUOU1GqwZLngfB9S3e9iXvMaZll+ 2q9ngb0UTFPPfK7W/Id9gsCSEqssPaB1skyCAMFribbkvd1x+8hFSbJ6wCp61Z6wRuRL tzEcOIvzHZG312p1CgMjS+hZ/UTrTr0OoiZMRgKWi4Zfcf5544/SoInm5SSgN+j7EBDZ IFhmSSp4mHnOiFCiz0I0Od4pIYuhRDVjJi9LNt/Ik+L1G6tH+7FGRFcic7iAGY7q/iVG vDLg== X-Gm-Message-State: ACrzQf0lcAiJe+T4qneg0Ynw6baXiC2G/UhjZRvl8YjRXpryYvdZdEpe yAWKtBkTUGmh2mtdx2lvA53+CCU7+5L3Cef2jQgbSec8fOo7Ag== X-Google-Smtp-Source: AMsMyM46orLd9Zzbvorhe4dAIqjzYTTrIlmh/gsyPUA+BM/EtR7w5YfnBCokhnfA/Y+ytXLqt+7ZlSiRv09Ib82lz8Q= X-Received: by 2002:a65:6951:0:b0:42b:b13:b253 with SMTP id w17-20020a656951000000b0042b0b13b253mr44134998pgq.555.1666890452869; Thu, 27 Oct 2022 10:07:32 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> In-Reply-To: <83r0ytl042.fsf@gnu.org> From: Gustavo Barros Date: Thu, 27 Oct 2022 14:07:21 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Eli, On Thu, 27 Oct 2022 at 13:09, Eli Zaretskii wrote: Thanks for looking into this. > Could you please set debug-on-error t, repeat the experiment, and post > the Lisp backtrace from the error? I take this means you can't reproduce? Anyway, of course I can send the backtrace. For some reason I don't understand, even though I get the message as described in the original recipe, it did not generate a backtrace (some error control somewhere?). I could generate a backtrace with: (setq debug-on-error t) (setq delete-by-moving-to-trash t) (move-file-to-trash "/path/to/org-mode") And it is (slightly edited, since it contained more info than I'd like to share): Debugger entered--Lisp error: (file-already-exists "File exists" "/home//.local/share/Trash/files/org-mode83g...") make-directory-internal("/home//.local/share/Trash/files/org-mode83g...") make-directory("/home//.local/share/Trash/files/org-mode83g..." nil) copy-directory("/home//path/to/file/org-mode" "/home//.local/share/Trash/files/org-mode83g..." t nil) rename-file("/home//path/to/file/org-mode" "/home//.local/share/Trash/files/org-mode83g..." t) move-file-to-trash("/home//path/to/file/org-mode") (progn (move-file-to-trash "/home//path/to/file/org-mode")) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) command-execute(eval-last-sexp) Best regards, Gustavo. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 13:22:37 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 17:22:38 +0000 Received: from localhost ([127.0.0.1]:59194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo6aT-0003Im-Kj for submit@debbugs.gnu.org; Thu, 27 Oct 2022 13:22:37 -0400 Received: from mail-pf1-f180.google.com ([209.85.210.180]:37744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo6aS-0003IZ-Jc for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 13:22:36 -0400 Received: by mail-pf1-f180.google.com with SMTP id w189so2257456pfw.4 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 10:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=v1LCH9UEDc2LBFsqa1IdwB7eX7OAVaKH121dicBQLgc=; b=YjsaJ0v0bNCTJ5em3ih7RExcmWp7tIvhKRdDMgMp1Zg5Y0yZyq5l0G3wZqjxwmDsy3 g+Dzx6Yctm9HSnWIDs9sSjJdeOj9YjHHy7dJSiHEq3WP7wnkDtHcpHI6pgA/+cGlCvyG 0x395HMIvzEz6FprCTFpOvadkeGLjbjau90HLo39paHxv1FD5xj4DxXiNR0Sqn+c0AFo p6sINu/vqbKi7yo/m+jt9sz6q0Lywm2hcMkYQuC2vJsp7P+q1GcQHRFPI0L9v0r0md1I T91sL75fREU99RzyaRcLPD8W3mIvlgQ+QBVtos2hO5p2IjidMCp/CLA4UslEbTrRumU4 9AXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=v1LCH9UEDc2LBFsqa1IdwB7eX7OAVaKH121dicBQLgc=; b=gqErKf9O6hQIMGXZFUFkABXzmbNp1iNUZsbmrpKXfp2L7Q+HEecW+4rwGxt/FR8FNY g47nQK8s74mILPEQPwG7/1uDdXrDSJSKZxJoXhkVwfJaVuXOWx+2Mp7uWDC+qQNe+c1/ az/23C8YqEa+lkCfOKmDg5ghwh27KuaSwh2jiEzWq7YFkdDbutBHatZaKblek8CWUj1H Rr9kDVdmTQU5FAbGhxZY87snva8OtQStTySLLDImhrD5AU9iT2ikSaz0Mg9OOlRsX52Q wD2mS8VwlR07u4ttkzVujdHxqKEUfBx6l7X3az/WReNp2f5UC6rgYMMk/5izDLQMlmab eftw== X-Gm-Message-State: ACrzQf0Dvg38R9BjNuNnxxrVeI/bnksD4c0BlIwca2fqt0dVNRDZtaJF 04gWFx9vUqGl4/c9rSUaa194lnBrr29G8Gqh5Y/sy69F/Hzscw== X-Google-Smtp-Source: AMsMyM6YBalk+3WLGZ8KozkCLt4XkVWqXDrFTkxQ+GFB898qtR5Z4baE1+yDEMLnA7pAfWTd7IjKDvQsUZ//HZrESv0= X-Received: by 2002:a63:84c2:0:b0:46e:f239:354c with SMTP id k185-20020a6384c2000000b0046ef239354cmr22528046pgd.147.1666891350593; Thu, 27 Oct 2022 10:22:30 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> In-Reply-To: From: Gustavo Barros Date: Thu, 27 Oct 2022 14:22:19 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Eli, On Thu, 27 Oct 2022 at 14:07, Gustavo Barros wrote: > Could you please set debug-on-error t, repeat the experiment, and post > the Lisp backtrace from the error? One more thing I just observed and which might be interesting in understanding what's going on. From trying things out to report now, my "~/.local/share/Trash/files" contains: org-mode org-mode83gQ8O org-modeAZxK5B org-modepKMpkM org-moderWcC2T The first one of them contains the full expected contents. All the other ones are empty. So it seems somehow somewhere we are trying to mkdir twice. Best regards, Gustavo. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 13:30:58 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 17:30:58 +0000 Received: from localhost ([127.0.0.1]:59214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo6iY-0003X6-0K for submit@debbugs.gnu.org; Thu, 27 Oct 2022 13:30:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo6iW-0003Wr-82 for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 13:30:56 -0400 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 1oo6iP-0000fZ-PM; Thu, 27 Oct 2022 13:30:49 -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=0DpGvZa08sUW9BwgaKvzPc/hAMOCC1CLVDD09g5F8z4=; b=TsEOUPjUcEaQ b5xqzVuTfEmaC80pMhal+OXxg+Qiql6aLGdEXzzUeiwB1n5eU2gb92u6bfAcew5L26oYiaUT3hoEu 1JoNwvLj+BA28jbvzF0oBPILa3XXUzuaXL6ot7dlu2KZx4BkchHjlC4RaLu4yHjuKoJ0WA8xrrZtQ ZooKWeGQbbXiniEXgMR23I4P2hLHVhIHXEnKADCPCRxqK1QOuuqOJ8pq+1XzVVlGaKrS+ulzG7crh RFW3orPWTpvL91dsSgWCtYSQ+KZbEKsAGEgF+UlPXugWrhgn7koD9X1uwH2GlJO7gbNaupTnSyVld H+UvlICiNvDVEDcXfxDjAg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo6iP-0008DG-7I; Thu, 27 Oct 2022 13:30:49 -0400 Date: Thu, 27 Oct 2022 20:30:42 +0300 Message-Id: <83bkpxkwcd.fsf@gnu.org> From: Eli Zaretskii To: Gustavo Barros In-Reply-To: (message from Gustavo Barros on Thu, 27 Oct 2022 14:07:21 -0300) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <83r0ytl042.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustavo Barros > Date: Thu, 27 Oct 2022 14:07:21 -0300 > Cc: 58721@debbugs.gnu.org > > Debugger entered--Lisp error: (file-already-exists "File exists" > "/home//.local/share/Trash/files/org-mode83g...") > make-directory-internal("/home//.local/share/Trash/files/org-mode83g...") And the directory by that name really already exists under Trash? That would mean something is wrong with make-temp-file on your system, because it's supposed to return a different file name. You will see that move-file-to-trash calls make-temp-file near its end. (I cannot myself try reproducing this because I don't have access to a system with freedesktop.org-style Trash.) Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 13:51:59 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 17:51:59 +0000 Received: from localhost ([127.0.0.1]:59263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo72s-0004BU-PF for submit@debbugs.gnu.org; Thu, 27 Oct 2022 13:51:59 -0400 Received: from mail-pj1-f42.google.com ([209.85.216.42]:55231) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo72q-0004BH-Qb for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 13:51:57 -0400 Received: by mail-pj1-f42.google.com with SMTP id h14so2281818pjv.4 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 10:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WO7NkP6z5mSnbGNQXFFO3BoIp0OKWetPXtq1A/txtqs=; b=T1HujSvj7JLMl0O2iMHy9/i+1FP7RBe899312ltgzwCtuYCGGF6dBapUz3THzX1MiX wRijcnBO5vbqZXLRZjNUfLLCJrQNp6O/kbLPgfOkbB+WS2JTL7U/ZZaN59OF9wSsvutG pb71mEEohMwY9HWFv6ptZzBFYXhZfYBVln+coamBm4IJSQjK4U2mOijxXjCJCyvl/V3Q LGh2RTpr+nPjwn0hepPcJbjDdxayoIFQNs+kaoeBi7xEvLWdAbY9leB8PPKGYpBQGGGA mRtgQee6AO9jS4IqVnm6AMOUak9w7QNvQMIPNpn64F3z37GkxK6GBwP5hMb6wpnrua38 jb2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WO7NkP6z5mSnbGNQXFFO3BoIp0OKWetPXtq1A/txtqs=; b=v/QF8zFxy7IZUt6R70nS9OXXOIjP9+IKUJhvOKE6K9RjRFZ56GkW4l6Mp1HuFfMLz2 saNmIU4N/1gz6dJN7HyvDSms9iizoTAqK8sHTwgH7iURCu/YSWX0uMf7FkrabPj1bMjw T3YoBlb7WGlrS270mNJpuaJ5Ec5+OAAhYrg/tpNGrm/nMsPfJZBzag71NIPZRmkSnZdl WxUF9a785S4Snw+W13Y5ToHiVUTnV97Gqi9m/GZUcsoUT9MiboS7Fxnl/1YPsJb+9jAA VOV6E9CTk5AWwZZlTjRt5L3YZmhU9njZyisXKtA53r5tklqszldIOhcUykGrHHUTnoT7 +GLA== X-Gm-Message-State: ACrzQf3HVx+mS2JOd7ijNevxmNaX8nj6K2tJghZWtu1a5iqb7BAA94DZ 41OruTk74478OOqWuW6hgzgmTYY9aG4yBFyWjdX4Hry6Eipwbw== X-Google-Smtp-Source: AMsMyM7WR+Y6iaGMy6icwKzokzcBOQuBkUgRRUkyQ5m9YV7nY2+JZ2o0FrnljZjeWoPuQ8zYnbvGw9NNUpBBgSdtOTk= X-Received: by 2002:a17:903:283:b0:186:897e:71ea with SMTP id j3-20020a170903028300b00186897e71eamr29359792plr.123.1666893110940; Thu, 27 Oct 2022 10:51:50 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> In-Reply-To: <83bkpxkwcd.fsf@gnu.org> From: Gustavo Barros Date: Thu, 27 Oct 2022 14:51:39 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Thu, 27 Oct 2022 at 14:30, Eli Zaretskii wrote: > And the directory by that name really already exists under Trash? > That would mean something is wrong with make-temp-file on your system, > because it's supposed to return a different file name. You will see > that move-file-to-trash calls make-temp-file near its end. Well, not like this. It existed because Emacs created it. Indeed, a Trash should be able to receive multiple files of the same name, and they must be uniquified somehow, and that's what Emacs is doing by appending a suffix to the file name. But, to be clear on the process. Before starting things, I cleared my Trash, so that "~/.local/share/Trash/files" is empty. I clone the repo, and move it to trash with (move-file-to-trash "/path/to/org-mode"). Now "~/.local/share/Trash/files" contains "org-mode", with proper contents, as expected. I clone again and move to trash again with (move-file-to-trash "/path/to/org-mode"). Now it fails with "(file-already-exists "File exists" "/home//.local/share/Trash/files/org-mode7AV...")", and "~/.local/share/Trash/files" contains: org-mode org-mode7AVOuq Where "org-mode7AVOuq" is empty. And "org-mode", with contents, is still in "/path/to/org-mode". > (I cannot myself try reproducing this because I don't have access to a > system with freedesktop.org-style Trash.) Understood, I'm at your disposal to send any information and perform any tests you need. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 14:20:47 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 18:20:47 +0000 Received: from localhost ([127.0.0.1]:59287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo7Uk-0004tw-Te for submit@debbugs.gnu.org; Thu, 27 Oct 2022 14:20:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo7Uj-0004tj-CP for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 14:20:45 -0400 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 1oo7Ue-0000lM-13; Thu, 27 Oct 2022 14:20:40 -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=uDKcTeS36kpj9pB2PU8nPiIBZjcsba6/84g8k/wRGxY=; b=MXeEgXccJ3r7 I0QjO/x42xW7T3Ea3F63noOKteljM3P+9WzxxFmgGpXkvDKZUv1mRhyQElWbXvAHe3DjnA4kalqGO asyNClISIngx+caVfrx/ijw35SNnpoaj2nIpWB1+UEgxy0OBtctSUm2ava56jwSzdGHTmcXTsqQVO HojJi9rGFBEMduJRg+nMUvfzj9dZDjIgolxhsOe/9c+K+4X7i58ImrzW7PveP7kU0V9rRGW2Gi/LA pib+Z1LaSkJqHBHPKzdLdoVDckQw62rKIR8Pr6PF6Ut453ce9AqpooSRYUUq9GuozM+RuI1OKkQJT gte97hyo0GyKg7NjNzuw4A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo7Uc-0002Jb-A0; Thu, 27 Oct 2022 14:20:39 -0400 Date: Thu, 27 Oct 2022 21:20:32 +0300 Message-Id: <838rl1ku1b.fsf@gnu.org> From: Eli Zaretskii To: Gustavo Barros In-Reply-To: (message from Gustavo Barros on Thu, 27 Oct 2022 14:51:39 -0300) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustavo Barros > Date: Thu, 27 Oct 2022 14:51:39 -0300 > Cc: 58721@debbugs.gnu.org > > I clone the repo, and move it to trash with (move-file-to-trash > "/path/to/org-mode"). > > Now "~/.local/share/Trash/files" contains "org-mode", with proper > contents, as expected. > > I clone again and move to trash again with (move-file-to-trash > "/path/to/org-mode"). Now it fails with "(file-already-exists "File > exists" "/home//.local/share/Trash/files/org-mode7AV...")", > and "~/.local/share/Trash/files" contains: > > org-mode > org-mode7AVOuq > > Where "org-mode7AVOuq" is empty. And "org-mode", with contents, is > still in "/path/to/org-mode". We need to understand when was org-mode7AVOuq created, and why does Emacs tries to create it again. AFAIU from your description, org-mode7AVOuq was not created by the first move to trash, so why does only the second move to trash cause the error? From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 14:42:05 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 18:42:05 +0000 Received: from localhost ([127.0.0.1]:59298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo7pN-0005QB-Cm for submit@debbugs.gnu.org; Thu, 27 Oct 2022 14:42:05 -0400 Received: from mail-pl1-f170.google.com ([209.85.214.170]:37469) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo7pJ-0005Pd-4P for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 14:42:04 -0400 Received: by mail-pl1-f170.google.com with SMTP id d24so2468301pls.4 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 11:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CaEPBJ4+ksGPZ6IZ20oPp5hTnDUlG+s6vOBfkT+CNmA=; b=oumdVid4fx84K8ZjQFckBfBHHYl/b9tTtiPOnY9NcSo/ZiFVEDPq7FOOaXd5LFpl4O wPZg/LIwUnRtZxY0bxQzyJBt5jRiISzXRwAGCpPcGdp84KK9IvvyNsT5Fe634b4LUZx+ aQeI5cD3q9wJXl3+cZwJ29C6rdbWr5xPwks6EXEj2lcspxl1QkosXb3UZPEq3GNzWD61 o1hWjFU0BzCFVHZn4wt3h3qGzVftaNHEERdXpmKIYN3QKtBBbFw6J3L6wFX2jbL83g49 zimMYIjIuMp0W3U8ihY3igzCGn934V/cVLkvVn96yn5HmhPZveh+hyBnjPQ4P5REA7yB X8jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CaEPBJ4+ksGPZ6IZ20oPp5hTnDUlG+s6vOBfkT+CNmA=; b=QOL0x3P7in5SZ1QEGmADb0uRQVhjlpzWmn28Dv0ZlarUrXO4Wufo3iNgTG8yCuW/a+ TAEC64xSogKP25eSNQHzHxzE3FMZ3gsMZtC5GJ9bBx/gW5DYzkmjP7BBEc1OXA1naX3Z 3/+GLzqjn+KtfBtlc+PQPSn7LZ0Epqta8MH/nbbOUBzwc58MGFqz1W6/eLzS6YTi/3rQ e9i3fBqN44R+LYoJ/o2olk3nDHO8NwDMTWc/86zxvAkyKqwPMMEjg2dd2o0akKk9lTJa +v+Ko1KP30rZuttcSb/wY+SON2iACCmBbA/9I69IFi5CY/JDWR/3n0a0T/favfDQhNhU TBbQ== X-Gm-Message-State: ACrzQf2B5fKRXlnjmABmiV8eDdnrFXhUIaaY78XmmtKUNKOwiMWjOFwf Ihq8Nm34BZepmrSqa1bSzEcMY/gqcyvIiGe2xRG5HVMRpRtZNg== X-Google-Smtp-Source: AMsMyM6N2VL9Mttwcrb4AKMkMiT6qQdUkUMll+ZM9eD4McjROTyVm/Ec6ZU2GB9+++D5AQuRcJlW4hJ4y2wdPuSA8CI= X-Received: by 2002:a17:90b:4b90:b0:213:6a84:b4e9 with SMTP id lr16-20020a17090b4b9000b002136a84b4e9mr6445288pjb.212.1666896115114; Thu, 27 Oct 2022 11:41:55 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> In-Reply-To: <838rl1ku1b.fsf@gnu.org> From: Gustavo Barros Date: Thu, 27 Oct 2022 15:41:43 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Thu, 27 Oct 2022 at 15:20, Eli Zaretskii wrote: > We need to understand when was org-mode7AVOuq created, and why does > Emacs tries to create it again. Agreed. > AFAIU from your description, > org-mode7AVOuq was not created by the first move to trash [...] That is correct. After the first move to trash, only "org-mode" exists in "~/.local/share/Trash/files". Indeed, at this point there's no need for the name to be uniquified, since there was no other directory with the same name there before the first move to trash. > [...] so why does > only the second move to trash cause the error? As far as I can tell, the existence of "~/.local/share/Trash/files/org-mode" triggers it. I'd presume that its existence takes the execution path to some code branch (the one which tries to uniquify the file name/calls make-temp-file) which tries to somehow create the directory twice. But there's more to it. In the original report I explained why I ended up "cloning the org repo" for this. Indeed, when creating the reproduction recipe, I've tried first to create a simple empty file with `touch' and a simple empty dir with `mkdir', but those did not trigger the error. This is utterly mysterious to me. Perhaps something like "size induced delay with some asynchronous process"? But that's just a (very) wild guess. Truth is, I'm at a loss. And I did go through the rabbit role to some extent, which resulted in that other report about `move-file-to-trash', but I could not understand what's going on here. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 15:04:49 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 19:04:49 +0000 Received: from localhost ([127.0.0.1]:59347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo8BM-00063E-RG for submit@debbugs.gnu.org; Thu, 27 Oct 2022 15:04:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo8BI-00062x-6J for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 15:04:47 -0400 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 1oo8BB-0007YJ-2M; Thu, 27 Oct 2022 15:04:37 -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=13ddARBBlrvJJyVirt7eokfxwXqjSmOeHtHxgd7ozc0=; b=G/677aZtYYVC WDJuZyExDGqEtG0vv6UXjap/nGWO/gv3LoUrCi2WAEi+oCxc4mHtSF6YL+4CblqwBa1xCdiWEx4Jo F4ZOwdOhebkzVOE1UfWyyKCBCz/V/5mZC5Ef5japyUb2udtSyfQFTTdS4Jq+k7mOqdYwAI4+hBQZG Rm/mCR7IstIL4GwWc+B2KVBaqJn8v3JN2Fj9PvfC8OEmH/fdOmObhvPQN+wHtYRHYOPRqbVivwZs/ MmagMYL/FyD5KhrC60mZ8uIbSixYBtjIBW08oGVdIo7020BP07hCmtd/iyFv9MypDKEdQcdNOfLdu i21Oe8u9SpFQTrfDzA6bIQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo8B9-0008Gd-1R; Thu, 27 Oct 2022 15:04:36 -0400 Date: Thu, 27 Oct 2022 22:04:29 +0300 Message-Id: <837d0lks02.fsf@gnu.org> From: Eli Zaretskii To: Gustavo Barros In-Reply-To: (message from Gustavo Barros on Thu, 27 Oct 2022 15:41:43 -0300) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustavo Barros > Date: Thu, 27 Oct 2022 15:41:43 -0300 > Cc: 58721@debbugs.gnu.org > > > [...] so why does > > only the second move to trash cause the error? > > As far as I can tell, the existence of > "~/.local/share/Trash/files/org-mode" triggers it. I'd presume that > its existence takes the execution path to some code branch (the one > which tries to uniquify the file name/calls make-temp-file) which > tries to somehow create the directory twice. Perhaps step in Edebug through copy-directory, and see what's going on there? AFAIU, the problem happens inside that function. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 15:07:37 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 19:07:37 +0000 Received: from localhost ([127.0.0.1]:59358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo8E5-00067w-2f for submit@debbugs.gnu.org; Thu, 27 Oct 2022 15:07:37 -0400 Received: from mail-pj1-f46.google.com ([209.85.216.46]:55203) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo8E0-00067g-5x for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 15:07:35 -0400 Received: by mail-pj1-f46.google.com with SMTP id h14so2480155pjv.4 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 12:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VxVmRAnMig5PKukgWhuSXttd1Gcq2ONrXWE0CoFAxd8=; b=KuXRvnw8gQc8FzqJaXAUV8b+97OmH0dnkDfKR+knkIIhJH55IHxQ5UigcPY5foGwVP iDRZqPdpFS4QZGk31cILa6NXjX0Q/HJ34gDqewDXMsfyhaCJAzKMrVWhUXkwWfcUMvC2 Mxw0vpO2ykxuin3IFpvJCCiITdZq8sMTYbWkJWQxmER6KtOGsP0CcmXeTycwyX3+8bs9 wHYWVShspxM+HyQe1MNC1+yAHf4sITu6v5AQDWGwuf1HQ2hzClM5ahkGYfFOqtDK78Cz X+GQn5hY7AuqNmMYIQdveYjNQqugCrpyWrMK3GtvUM3Maef7yf+nk5cMD36ls5gmWkkb TQaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VxVmRAnMig5PKukgWhuSXttd1Gcq2ONrXWE0CoFAxd8=; b=5w1g996pSBg/Pw6TzV3TRWE9LxpbQ0CkSPhcuYgMKXQ/4/BWw2KPh9AKJQpaqgL8Qm y+48YY06Qj1XsAI9dWU/OE9/5z2P+fnMMO3ZuxXq6R+DNTaKz4oNspG9kH4ENif8Xfw1 vansJ+te9YKD20AIMTQADOvsEM558P3h8OucvwCtmmrMn4UQeNnupiamHwYljFlibvPD AyOHT7j3w/ophtFNpsIA4BIVQPS/ySMS3REdyhrK15xwt3dEhl23ahdeG2GwXtQwnxAb 03lsNppq4YIqcv9IrUlfKsh+tWhH5Mu4q/fzHk2kGMGtWYd6at0uESXq3ppwnr7IqLuH pVAg== X-Gm-Message-State: ACrzQf27UC78+8YonbB84RUKPfPsoyl+arIeMUaCPkKpLvxw2OYJBIAo sgVLfKZqqMQxoj7sSQFwbm7nA1JseoUlyDP28EsPOULEgKZmNQ== X-Google-Smtp-Source: AMsMyM4gpl0W18ViP5wIh0TsK4Z/cgysxMhhZBny9+4T0oLNu7uOcZQVcAWuNPoqTUpghue4rd+3vXIfXnpzgdJFOLA= X-Received: by 2002:a17:90b:4b90:b0:213:6a84:b4e9 with SMTP id lr16-20020a17090b4b9000b002136a84b4e9mr6551744pjb.212.1666897646245; Thu, 27 Oct 2022 12:07:26 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> In-Reply-To: From: Gustavo Barros Date: Thu, 27 Oct 2022 16:07:14 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Thu, 27 Oct 2022 at 15:41, Gustavo Barros wrote: > > [...] so why does > > only the second move to trash cause the error? > > As far as I can tell, the existence of > "~/.local/share/Trash/files/org-mode" triggers it. I'd presume that > its existence takes the execution path to some code branch (the one > which tries to uniquify the file name/calls make-temp-file) which > tries to somehow create the directory twice. > > But there's more to it. In the original report I explained why I ended > up "cloning the org repo" for this. Indeed, when creating the > reproduction recipe, I've tried first to create a simple empty file > with `touch' and a simple empty dir with `mkdir', but those did not > trigger the error. This is utterly mysterious to me. Perhaps something > like "size induced delay with some asynchronous process"? But that's > just a (very) wild guess. Truth is, I'm at a loss. And I did go > through the rabbit role to some extent, which resulted in that other > report about `move-file-to-trash', but I could not understand what's > going on here. I just had an idea here to test the "delay" hypothesis, and it paid off. All of my tests so far were being done from one of two places, the "/tmp/" dir, or the place in my user files where I keep Emacs cloned libraries. And they share a characteristic in my system, neither is in the same filesystem as "~/.local/share/Trash/". "/tmp/" is a tmpfs mount, and my personal files are in a separate encrypted partition. Hence, what I did now, was to follow the recipe, but instead cloning to "~", which is in the same partition as the Trash. And, guess what? The error does not occur! So it seems indeed a delay is at play. And that this one is related to bug#58781, after all. A "fix" there would "fix" here too. But by luck, because it would make the move "quick enough". However, the behavior does suggest there's really some double attempt to create the directory somewhere in the code. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 15:13:38 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 19:13:38 +0000 Received: from localhost ([127.0.0.1]:59372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo8Ju-0006He-FS for submit@debbugs.gnu.org; Thu, 27 Oct 2022 15:13:38 -0400 Received: from mail-pg1-f169.google.com ([209.85.215.169]:46039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oo8Jp-0006HN-H6 for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 15:13:37 -0400 Received: by mail-pg1-f169.google.com with SMTP id r18so2464552pgr.12 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 12:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=c9PlcTlM9i2o05/jzFDqhChfAUpYmi2d78E1aJ3tohU=; b=h294x6QZDKBhSouM66jG4EiHh6LBSQQsdgZUq9c8blC1/AGXQVZmVz3VRBKgAJXYDy mq7CcysPi05wqerO+LaPQBCmYSrMhyVqQozKAKw0g2LrheesUH16+mSvOpOB0iVGmDl/ UDaNy3RJ4+NnzIwmw9MdmnxleZgxVV6VownO9QkuCUP6eY7k/8et2TMKKis3Jd5GSAJ/ MjScCXj2YPmiYfRlB++fd2hVvtX3xFYCFU/0vPJOkqXiSyno4E86DEpc5lvVjFXUKbxL ZrWEWs1kmGzimdUFPa61svzj+G9YeKUGB/XpqmF/U0DmX1r0NDmSIqyD6KHnRqKEZgpB 4wXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c9PlcTlM9i2o05/jzFDqhChfAUpYmi2d78E1aJ3tohU=; b=pV9O/HZMlds5uyQoNFoZ/bH9AlybeTkyjO6QadvvaTyLceaWMCit+hGUKyHdZSVInd rTgwrMPa7dq3/ls+wXQiu2s4QioHWxuZ91MJlmJyoA957OxzJTt98gAXQPZqf4bO7ZXb hEJvqSjtcBAhA4GGe9p+1KPqOA6mxyr9bgML2eVfxN7DaIRQasCX5CbSyOnSEXpmG7w2 KTZhmv2W6bsXJnknayEWJgHhoisB/D4CnqiSOW/teKlCOM6xWg9nCIm3jfdNVneztNHm fNVNOzBO5X+lvZ/M7A0GGihB1kwf0IiH035tReaRR59YySR5R27hYjlw1MEwDAxYl1h5 pXaA== X-Gm-Message-State: ACrzQf3X5tUj3cramQLtIlSfRASUMZwkq4UnZ3TqDPNSYGdsKpCpftFi tJHgC8oGfY8skON0buCyXnrA5yPNVogzX+08CIg= X-Google-Smtp-Source: AMsMyM4X/kUJStnXeELH9DOOKO2si1DWZzECAm1Yg3mITcFA2LxnEwJ/aO/M3SV0kcch/x4Rq5VVngguSQ/RlFvukS0= X-Received: by 2002:a63:84c2:0:b0:46e:f239:354c with SMTP id k185-20020a6384c2000000b0046ef239354cmr22877102pgd.147.1666898007762; Thu, 27 Oct 2022 12:13:27 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> In-Reply-To: <837d0lks02.fsf@gnu.org> From: Gustavo Barros Date: Thu, 27 Oct 2022 16:13:16 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Thu, 27 Oct 2022 at 16:04, Eli Zaretskii wrote: > Perhaps step in Edebug through copy-directory, and see what's going on > there? AFAIU, the problem happens inside that function. We were both replying at the same time. If that's what you need after seeing my message which came right after this one, I can try to do it. (I may need some guidance, but let me try by myself first before troubling you with that). From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 27 18:01:48 2022 Received: (at 58721) by debbugs.gnu.org; 27 Oct 2022 22:01:48 +0000 Received: from localhost ([127.0.0.1]:59581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooAwd-0004ZZ-Nv for submit@debbugs.gnu.org; Thu, 27 Oct 2022 18:01:48 -0400 Received: from mail-pl1-f173.google.com ([209.85.214.173]:41595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooAwb-0004ZH-6N for 58721@debbugs.gnu.org; Thu, 27 Oct 2022 18:01:45 -0400 Received: by mail-pl1-f173.google.com with SMTP id io19so3056346plb.8 for <58721@debbugs.gnu.org>; Thu, 27 Oct 2022 15:01:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=e/eShk6GgLfEpcKHYugtpfCEdvkiV9sZXRTRO/IIgSQ=; b=U3inat6gZzg2R8Gu+eElKWPV4HqLMGwVa6J+NKlarRtaaRD9DWMDZrIR3zDnqSREWO BvP80P0cR4QXgNgaXzW1ad8Z6GLH1MI2q7OyfLZHUmcguqk+uhR7BSJlLKZM0wn6Traj lk13utlvYxp5Jzw81l6x73rs4ZkMANXbwgufMSCFqSVXAfO7IiiKR2QQPtSi/jjVM59Y Qqb7Oct4zj+FqaSV9QREVHGmm2NYFBNtP9bg+vQwFRUAf6RD+t9nDgTac4sAGAL9Dhci SmNYucyzBnZhPRdoBS7pGUvb7FmUuPIYW/1zsxvbn7qmae+cWxizpS1jGU396VJKaVIY TOfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e/eShk6GgLfEpcKHYugtpfCEdvkiV9sZXRTRO/IIgSQ=; b=eYTvSSLZsLgXk+EF4FUhdBYVR8vZ9zfk6MEJ8Yte6txrgMGWTiuwr0AYMyQkMpKBgc dcOUbKAoaKKL6dTj7rKFYwlfAKpXiEbCK4LuvG/DzrECwRLlGS4W+uV3NTrmI00/Ee3h aU0d26t9WtZeRkh9uoTQomZNEB4oRERwbyL5jF6224dvrm7ehqPjDYTzoOzzMn6mOaAB dthmisXO/NyW6Jwpd+SgRkBnsZLDaIeOYkORLEcV4RF6B3i3m+WVrfFIzNUfOp+zP+V3 u8mZKFLu31WpyeZHP3q/B+HojRh0rC2ow4J14mjFIHoZWRXDS7me5jqTBiOlONcXoTIq LQDg== X-Gm-Message-State: ACrzQf2VM32+Y39ogGq3P5S/XtVBQWEHuc8kor9xC3+lCh1rPmSWwARU DbZ2U+lQizHjfDUY17CQ6lUuaHhv5VZ/NRvgJss= X-Google-Smtp-Source: AMsMyM5vhfiBPqlu2Pxoxo2+vST51iiwdpka0hInqukpl+tEOYNbaz5AG8Y8SjfLA8e8KliFsn7VdtPbAizRoiH7RzE= X-Received: by 2002:a17:90b:4b42:b0:20d:954e:28d with SMTP id mi2-20020a17090b4b4200b0020d954e028dmr12714725pjb.93.1666908099084; Thu, 27 Oct 2022 15:01:39 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> In-Reply-To: <837d0lks02.fsf@gnu.org> From: Gustavo Barros Date: Thu, 27 Oct 2022 19:01:27 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Eli, On Thu, 27 Oct 2022 at 16:04, Eli Zaretskii wrote: > Perhaps step in Edebug through copy-directory, and see what's going on > there? AFAIU, the problem happens inside that function. I think I was able to narrow it down a little. The empty directory is indeed created, when the file already exists, by the call to `make-temp-file' at: (when (file-exists-p (file-name-concat trash-files-dir files-base)) (setq overwrite t files-base (file-name-nondirectory (make-temp-file (file-name-concat trash-files-dir files-base) is-directory)))) But, at the same time, the `overwrite' flag is set to t, in this case. I'm not sure why the file is actually created, I suppose that it is to "reserve" that name and ensure nothing else takes it in the meantime. At the end of the function, the call is done to: (rename-file fn new-fn overwrite) But, when the operation is crossing filesystems and the file is large enough, the `rename-file' will fail with "file exists", despite the `OK-IF-ALREADY-EXISTS' argument being `t'. You can try that with: (make-directory "~/.local/share/Trash/files/org-mode-foo-bar") (rename-file "/tmp/org-mode" "~/.local/share/Trash/files/org-mode-foo-bar" t) Provided "crossing filesystems" and "large enough" we get (I do, at least) "(file-already-exists "File exists" ..." WDYT? Can you reproduce this? From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 03:47:10 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 07:47:11 +0000 Received: from localhost ([127.0.0.1]:60256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooK58-0006kH-N5 for submit@debbugs.gnu.org; Fri, 28 Oct 2022 03:47:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57650) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooK56-0006k3-Oc for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 03:47:10 -0400 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 1ooK51-000787-Hs; Fri, 28 Oct 2022 03:47:03 -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=C0zsbBeh0H917P3BhK6MaSjDsI4Yt2obnDD5NP7D9tE=; b=U6prQ+9dOYoc y9KHtpFqp1hlX+kqKjbfgAOudpIDB6E7DihLENVRb2J5Th3VcyCNwx7k6WTLr2qVukFHcLpVzeBr+ TupTnJ0WsLwfASCb1VIu7dwjlEk6dyjq9Ru89Dnk8n1dogcI2Mvn7D23c5cJwIIGEF/HybJyYI61A mCSSlYG5xFXYPA3adkLPfNfP4r2XE1jEZp2hHFC1ohrb+avLNraXH1K/6voby4UmZF9yGXN3atmzp vpI55dr56juq1Reg7HKhyZAz3/SgJge9BZgn9PXpPeJl7zCVKqArSMjZaj4E8TzdFlU7lFnkdTYbz dpxUzuQzonQCRLg6ANigaA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooK4z-0001ni-MC; Fri, 28 Oct 2022 03:47:03 -0400 Date: Fri, 28 Oct 2022 10:46:56 +0300 Message-Id: <83lep0jspb.fsf@gnu.org> From: Eli Zaretskii To: Gustavo Barros In-Reply-To: (message from Gustavo Barros on Thu, 27 Oct 2022 19:01:27 -0300) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustavo Barros > Date: Thu, 27 Oct 2022 19:01:27 -0300 > Cc: 58721@debbugs.gnu.org > > At the end of the function, the call is done to: > > (rename-file fn new-fn overwrite) > > But, when the operation is crossing filesystems and the file is large > enough, the `rename-file' will fail with "file exists", despite the > `OK-IF-ALREADY-EXISTS' argument being `t'. This sounds very strange. Why would the failure depend on the size of the file/directory and on whether it does or doesn't cross filesystems? I see nothing in the code involved in this that could cause that. Perhaps on your system something happens in the background, due to one of the filesystems being encrypted or something? From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 06:43:28 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 10:43:28 +0000 Received: from localhost ([127.0.0.1]:60480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooMpj-0007Hi-Qk for submit@debbugs.gnu.org; Fri, 28 Oct 2022 06:43:28 -0400 Received: from mail-pl1-f177.google.com ([209.85.214.177]:45824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooMpi-0007HS-0k for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 06:43:26 -0400 Received: by mail-pl1-f177.google.com with SMTP id u6so4493296plq.12 for <58721@debbugs.gnu.org>; Fri, 28 Oct 2022 03:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oMAWtOzdJlLXcEuhyvB2e5wDwLuzst4ca1wU6rcr0u0=; b=KjblG0zWDvOC12OvG/pG3wrMMKy3W/vw1YLR+SgqQOVR/FVgZzt4sFoyIvQuHhzT8N LMjOy7gJzYD6is3Obg2Wta+8gbrU5Yk8fhMwXJdwM7jQ0D5POQPuVZaJzX3fAFm8qMRE hNAPJIiQMIcXzsTe1uIwN1UQxDw+Kz8/uxb+JWLMqQquC3s0Gda1rHux/lrQ1mL243xR 69l4AJ7DYKHctI/Lt/MCvrKmbaZac61Nvm7ItQWECZSYX9e5fn8PIJTWIY0NIzvrRAa1 WCOtwpMpiGJCJA2UfnKzUnltB+QK6j0MUakPy/dEBLD6uJjwLZmx1M5xSZN/YICT0b9J 4VAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oMAWtOzdJlLXcEuhyvB2e5wDwLuzst4ca1wU6rcr0u0=; b=VoyVHsQlvMGsV+Edg53enZ7u1cX2CX2UaA0XCfg6gaBs5jpzpn6JhTxe5kh3pkA2RX +xfqhha2HXmgXeCODKAUHXJ2dDdfwEugKOhZxGjDQQwPqaaphJ+b9wM3Q5zjfrzVcEYz ZfMO6gj2n7+ygsPkeue6FdEiqP8Y6YvvN5iTtpUnnxHMaQj3Ic3T27FON8FB15lkxIcD ui32RCKNiBsj43Z5eOcAZ6xvT9HjClBxQQCvPPSp2RrY5yyyjrBxGY3sg6aB1efiRUBW l6owlk08skVd/Rx48lxel7f+14w99/hVlvPXdchOk4ErRzwjD59oH/JsES4AagC0rULy 4o/w== X-Gm-Message-State: ACrzQf3CwFFQ0okI7RlWbGUMm934ew+Qf65MKlb/nDtctegekZ974oDW su7HGX6AwqnWytBYvZoPlPQosbRssXXsfWe6LyA3A2+5KrR18g== X-Google-Smtp-Source: AMsMyM71jLacRHJFVlE9H1PVH1jKQNzWCsu3ILqmHFb10f86+B5PFNNEBhIjYWTR9JUQgzSISPBHyeUPjarcIFUn6yk= X-Received: by 2002:a17:903:283:b0:186:897e:71ea with SMTP id j3-20020a170903028300b00186897e71eamr33087940plr.123.1666953800098; Fri, 28 Oct 2022 03:43:20 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> <83lep0jspb.fsf@gnu.org> In-Reply-To: <83lep0jspb.fsf@gnu.org> From: Gustavo Barros Date: Fri, 28 Oct 2022 07:43:08 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Fri, 28 Oct 2022 at 04:47, Eli Zaretskii wrote: > This sounds very strange. It baffles me too. Yet it still fails like clockwork here. > Why would the failure depend on the size of > the file/directory and on whether it does or doesn't cross > filesystems? I see nothing in the code involved in this that could > cause that. Well, "crossing filesystems" and "large enough" are admittedly a working hypothesis. I don't really know that's what makes it fail. I just know that I could create other cases which do not fail, out of these conditions. I take this means you still cannot reproduce... I'm sorry, I don't know what else I can try, I'm out of my depth here. Do you have anything you'd like me to try? Can anyone else reproduce this, or is it really just me? > Perhaps on your system something happens in the > background, due to one of the filesystems being encrypted or > something? The encrypted partition is open and mounted, as far as the system can see, it is just another ext4 partition. More clearly, it cannot be encryption per se, since the "/tmp/" folder is not encrypted at all, it is just a tmpfs mount. It's fstab entry is: tmpfs /tmp tmpfs nodev,nosuid,size=6G 0 0 Of course, it might still be "or something". But I don't do anything out of the ordinary here that I'm aware of. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 07:44:43 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 11:44:43 +0000 Received: from localhost ([127.0.0.1]:60534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooNn0-0002dn-RL for submit@debbugs.gnu.org; Fri, 28 Oct 2022 07:44:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37028) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooNmy-0002da-0l for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 07:44:41 -0400 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 1ooNms-0004Oa-QP; Fri, 28 Oct 2022 07:44:34 -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=snlhuWz15v4YNMva7wY7aGgg+gLZN6zTErwz26M+iQo=; b=YtNp3zVDV3L4 rDiGDYUKezOxkkeRjrlcUMb+iS+BcJ5l5c68nzrtMawEZHDz+Cyk/nD24nUie1z8XoYRC1c0TYNu+ UOE91eTRM8NLwrl2J+iCu2n+ES6HfozzJpYRUBwoYowYiYYdHhrNEu0smBevUQZLM47YD/g0omsGe pd54aqx7Af1j0C4HVyp61UkJr4uqLfnrbuh9bZHuetkdUDMWwuTb13XEuqXUnjJ3vVgd9y8DsZIJ+ BEPRkCJpcKUgJVq0eBLVh0rzInu7GL9H7K5/4Fo5vi3devvZgfi6PPwb2rKETAgrasYO0YkTOdX94 xqxib+kZjxRwBJ0bwsiFAg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooNmr-0000uK-VX; Fri, 28 Oct 2022 07:44:34 -0400 Date: Fri, 28 Oct 2022 14:44:29 +0300 Message-Id: <83edusjhpe.fsf@gnu.org> From: Eli Zaretskii To: Gustavo Barros In-Reply-To: (message from Gustavo Barros on Fri, 28 Oct 2022 07:43:08 -0300) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> <83lep0jspb.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Gustavo Barros > Date: Fri, 28 Oct 2022 07:43:08 -0300 > Cc: 58721@debbugs.gnu.org > > I take this means you still cannot reproduce... I don't have the necessary configuration here to try reproducing. You said it doesn't happen when moving to trash just a small directory, so it's quite clear that something specific to your system is at work here. > I'm sorry, I don't know what else I can try, I'm out of my depth > here. Do you have anything you'd like me to try? Try figuring out why the make-directory call fails. What is the name of the directory that fails the call, and why? > Can anyone else reproduce this, or is it really just me? Yes, if someone else could reproduce, it could help. > > Perhaps on your system something happens in the > > background, due to one of the filesystems being encrypted or > > something? > > The encrypted partition is open and mounted, as far as the system can > see, it is just another ext4 partition. More clearly, it cannot be > encryption per se, since the "/tmp/" folder is not encrypted at all, > it is just a tmpfs mount. It's fstab entry is: > > tmpfs /tmp tmpfs nodev,nosuid,size=6G 0 0 > > Of course, it might still be "or something". But I don't do anything > out of the ordinary here that I'm aware of. Here are some questions for you to try to answer: . Does this happen only with moves across filesystems? . Would any target filesystem do, or just some special kind(s)/ . What is the difference between the first move and the subsequent moves that triggers the error? Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 08:36:05 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 12:36:06 +0000 Received: from localhost ([127.0.0.1]:60610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooOaj-0006AX-BD for submit@debbugs.gnu.org; Fri, 28 Oct 2022 08:36:05 -0400 Received: from mail-pg1-f178.google.com ([209.85.215.178]:38455) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooOah-0006A1-7E for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 08:36:03 -0400 Received: by mail-pg1-f178.google.com with SMTP id 20so4719100pgc.5 for <58721@debbugs.gnu.org>; Fri, 28 Oct 2022 05:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=US2GSfFC4L9PADTC24I18vJhHy+BZY7f2B6N4gvaZck=; b=O0ZXbnx4GrcJT9DygYsE+iui8WPwB5O1xnBK1ty7QgOVKQQXLD20XExtSL3yOLl46+ TCFqMhqGp2RheeySWUWzDh9Dx6FSsqJJJDSiB+eQssowtkw+V1PnlGxuhazy7JXlL3v/ nnHwpDG22cic2cZSfo5cF0rRu90+Yxjp9tDX+p1vrupoe5rr+YBpzokOZvUiOyMHHFeb ZqmJtYqdGraXsRaF0ABJVOZ6Io55sJ3+ywKs1QHUCBVPOvDGRJknsheA3GvzFShJ4aHU OWHUhfsvt42eqkIKrwb1LJ6g0/LcFktW862QmJbAENnyFSoApt3suVtnEu/G8Ilk9ZsY Gs5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=US2GSfFC4L9PADTC24I18vJhHy+BZY7f2B6N4gvaZck=; b=McvP7orc42f3iNMQPB+FoyiLjHLE4ZWJZ9G3WvEQJXMAJ1SXafUZez/Y1E+ZWLuZdB ZWfbfahCOhPkk/XPAZIk7e9JcAh0bcxEoHjsfUTe/kSCSX7toFM8+Oh8L/zXUk1Xjlfo tJUyzScdta30IzBXgjvvEoFJ7WfGuSrmPi6eTANLvFEoaT3ian880yCyEaNZEQuTCeTt i19QKWo7x2lrTLnKft2RLzpBf0BapQY+cHzH3kqzmUvBH1mVJEV966krpJbtZFpea8XP kkxtLTXvpKDux143JNDD38A6fCpEMQ/CM25IohwzDaJxYOYkCUbmoE21fhiDa4YImrq9 WxNg== X-Gm-Message-State: ACrzQf1tChGWhNcb8bcYSHRoki4+EbUHr/QcvTUaLCAP4dcJB3rEI+77 ix3OkaUShVT6wxRAredkfRqteZoiXHlXwDe8RmYDYzp7May8LA== X-Google-Smtp-Source: AMsMyM6taKPemUcsTfuG/Jj6/Hd9qYB0x9Wof3zVvHdrLQqojo5n/R1BfPrkgNJhLWLmMWLwljJ2FsKdWOu9xXTsFr8= X-Received: by 2002:a05:6a00:1a44:b0:52a:ecd5:bbef with SMTP id h4-20020a056a001a4400b0052aecd5bbefmr53657978pfv.28.1666960557317; Fri, 28 Oct 2022 05:35:57 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> <83lep0jspb.fsf@gnu.org> <83edusjhpe.fsf@gnu.org> In-Reply-To: <83edusjhpe.fsf@gnu.org> From: Gustavo Barros Date: Fri, 28 Oct 2022 09:35:45 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Fri, 28 Oct 2022 at 08:44, Eli Zaretskii wrote: > I don't have the necessary configuration here to try reproducing. You > said it doesn't happen when moving to trash just a small directory, so > it's quite clear that something specific to your system is at work here. This is no longer about `move-file-to-trash', but about `rename-file' third argument. So you don't need a freedesktop.org Trash to reproduce. Of course, it doesn't mean you can reproduce it, since there might still be something else which is system specific. I've tried to isolate things from the Trash issue, and I could reproduce the problem with the following steps. I grabbed two USB sticks, formatted both of them with EXT4 (I used Mint's "USB Stick formatter" tool, I suppose it is pretty standard in what it does), labeled each "orig" and "dest". Mounted both. In the terminal, I did: $ cd /path/to/orig $ mkdir barbaz $ cd barbaz $ dd if=/dev/zero of=zero.file bs=1024 count=204800 $ cd /path/to/dest $ mkdir barbaz-foobar I started "emacs -Q", and issued: (rename-file "/path/to/orig/barbaz" "/path/to/dest/barbaz-foobar" t) And got "(file-already-exists "File exists" "/path/to/dest/barbaz-foobar")" > Try figuring out why the make-directory call fails. What is the name > of the directory that fails the call, and why? I can try further, but I did try quite hard already. And I don't think this has anything to do with particular names, I used foo bar stuff above on purpose, and they are our quintessential "arbitrary". > Here are some questions for you to try to answer: > > . Does this happen only with moves across filesystems? Formally, what I tested is that when I tried the same recipe of the original report, but with the "org-mode" directory I was trying to delete/trash located in the same partition as the Trash, the error did not occur. So, the answer is that, as far as I can tell "yes", but the reasoning is based on small sample inference. "Educated" perhaps, but I can't make a rule out of it. > . Would any target filesystem do, or just some special kind(s)/ In the example above I used standard EXT4 ones. I'd say this should work on them, but I haven't tried other ones. Would you like me to test anything specific in this regard? > . What is the difference between the first move and the subsequent > moves that triggers the error? I think this question only applies to `move-file-to-trash', we don't need "two moves" anymore with the example boiled down to `rename-file'. We know `move-file-to-trash' does create an empty dir there, and this only happens when a file of the same name exists (which required the "first move"), but it also sets the `overwrite' flag, the problem is that the flag fails. Thank *you*. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 11:26:24 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 15:26:24 +0000 Received: from localhost ([127.0.0.1]:34078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooRFY-0004Ty-D8 for submit@debbugs.gnu.org; Fri, 28 Oct 2022 11:26:24 -0400 Received: from mail-oa1-f46.google.com ([209.85.160.46]:43543) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooRFV-0004Tj-Nt for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 11:26:23 -0400 Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-13c2cfd1126so6625682fac.10 for <58721@debbugs.gnu.org>; Fri, 28 Oct 2022 08:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=aZ/DFvte+Czwdk8NlpaMhb6wXYjEnns1tsu3aQaR4r0=; b=Pupe6K7NMtcop4UYo4Bf7nN5clqe3FZyUHkLU/svlixP5cIUUt4UvT+tEfUMpHJc8T m+gdLpQ9dn1OGlB9nV2v67Ju+Ca7jQJIzl2RaED1+f2M3K2tG9LLJjUUYkSaSg1R2NUq zJ1GDR2l7udAbRJC2B//yBHTZ2XJNBjKyjuvG5wq23/PbpnNGWY9H6yTxAJvXUs1r7Vk 2l2P1pA1IHUDLyljLWzI+e2hgVxz7cnyvdpXNYmSH5jvJM1AnQuqavZPnAO7grIAbCxD v64mIRB/5CC/xaXMON+8DGag1n8sA1EYOQdlIn+UnLPLrGNtld3V2vl049nb6bnLJMLW ZsFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aZ/DFvte+Czwdk8NlpaMhb6wXYjEnns1tsu3aQaR4r0=; b=X3MZaJiQUJqk+ug6tJrbCQGe2xPp6nP7oQskNSoxiNXMZVGdXuCRIs1r5yGLHWbU4A 9gRaTWhywRf9nzLdzvn2/qzCrST6Egcexiv+86ugELy9tQrcYXyd9k91blmbEbq1Fhqf jOsH6xBAG/neeaRk5iRj2dutbeAivuapeH7pl53cEbcBxtc/GfGzEBFMM+MwmIVmMmdd PiHXLiUcFeOcd5GJtmWdd7RljfuJS9PpSSALOSo4RPcF5/wFdh8Rgk5c4hz6JlI7mqpD 6Ua+SHmnUvcWTpPJSPxZGBg6r8SBrbHEU5/KzP0r7/nim5hFrgMN5OeD0h4R7EYhPHgm fBEw== X-Gm-Message-State: ACrzQf129IeCrQfBx6hYZJNdnXlegAeO0qtu3thioImzt93vMC5q1h0Z Yc451vEonYLxNZJNPDQdz+W67dpOB4C2oJhpKwg= X-Google-Smtp-Source: AMsMyM7DVjSFkfeD6T1rka4I4MH7fkwuP5IkM4yVMchdLTYUDX14wtz5YknebB5IQReGkxZ4UKWVMZAx+rqvEDYz+xw= X-Received: by 2002:a05:6870:d79a:b0:136:50d7:faa9 with SMTP id bd26-20020a056870d79a00b0013650d7faa9mr9137462oab.92.1666970775931; Fri, 28 Oct 2022 08:26:15 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 28 Oct 2022 08:26:15 -0700 From: Stefan Kangas In-Reply-To: References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> <83lep0jspb.fsf@gnu.org> <83edusjhpe.fsf@gnu.org> X-Hashcash: 1:20:221028:gusbrs.2016@gmail.com::7a8aRiIPOrAYv/mh:1lDC MIME-Version: 1.0 Date: Fri, 28 Oct 2022 08:26:15 -0700 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Gustavo Barros , Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Gustavo Barros writes: > I've tried to isolate things from the Trash issue, and I could > reproduce the problem with the following steps. > > I grabbed two USB sticks, formatted both of them with EXT4 (I used > Mint's "USB Stick formatter" tool, I suppose it is pretty standard in > what it does), labeled each "orig" and "dest". Mounted both. > > In the terminal, I did: > > $ cd /path/to/orig > $ mkdir barbaz > $ cd barbaz > $ dd if=/dev/zero of=zero.file bs=1024 count=204800 > $ cd /path/to/dest > $ mkdir barbaz-foobar > > I started "emacs -Q", and issued: > > (rename-file "/path/to/orig/barbaz" "/path/to/dest/barbaz-foobar" t) > > And got "(file-already-exists "File exists" "/path/to/dest/barbaz-foobar")" I get the same result. But I think this is expected, as the `rename-file' docstring says: For NEWNAME to be recognized as a directory name, it should end in a slash. So this function seems to be working as documented. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 12:06:34 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 16:06:34 +0000 Received: from localhost ([127.0.0.1]:34138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooRsQ-0005XH-CU for submit@debbugs.gnu.org; Fri, 28 Oct 2022 12:06:34 -0400 Received: from mail-pl1-f174.google.com ([209.85.214.174]:39684) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooRsO-0005X3-QH for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 12:06:33 -0400 Received: by mail-pl1-f174.google.com with SMTP id f23so5222350plr.6 for <58721@debbugs.gnu.org>; Fri, 28 Oct 2022 09:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ntn4u6EpasMGGE7SebVMvK5yiiFnKv2KMSPvG6Y4Ifc=; b=BN0ZSiEoiOgdN67QfBkS1CxnjKVq6yr+A8zYEiWZmXvKvoJtl4X0/4SPyzrSHxhXkD cH0hB0vUr9LYIndGw80fSFz0Z1gEV0eyGUxs6G0UOg1gqPpHa7jOu6LvLQoKkInpHl9m b2V2w28EUnJ7/5rT4+0Qdr1iobWD3zZpdcpmUJouwI7+Q4TIb4omRk6cwHpI6NYY7fgz IQlKqkpqJXGLHELHBQAzkNjTSRcB9lMr+4sPtXjGz5Rev20ffj5fOLaht9HGaj3B4DTK nOOOiCK+00fUPqm04C4MM55uXH8CPE6rbtOxzYtDIRFT08eMNqepwFn/BSri/GEMTdg1 YUnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ntn4u6EpasMGGE7SebVMvK5yiiFnKv2KMSPvG6Y4Ifc=; b=R5LvyiEcCYQgdXvlgiFaJcGVwbtP/K7S3OVcwaHhHFS5vAZxtEHvfJ4LLsSCZ6ChS6 Rx2Ca70HjF0hiX8RLT5VHtX7KSd5apd9W9Z7rCZv+h1vv9Wh/dXpOfG22sNeEDT++W8d 3KbiUJ9O0Wf299k7GI3O3o7ymBP8/xFYEDJ+2rPdpAN0n/6DyTQt7Wx70y2XI8kBBntE VzdBN5TyDZWfXBXpA7bJDVGuDFB+AfEGPBWqcOrb6gWdgddLr0aBYRzK7KwmD1/1t6xn sqVBpIK3BlLibbwv8Y+fb/HAw2WM9fRObjjkhGyN+ej26xEQE1KajIfYZDcREAoNOR/E MKUA== X-Gm-Message-State: ACrzQf3IJrtkErtcsEqL/oZCqUD5Ad9NDj+ypimgdax5W84jH03U0RvJ i50utbkI+mgA1xHLEFOX5xRZXY8dvqJ/MOcd5W0= X-Google-Smtp-Source: AMsMyM7unfGbbRoFbJK4YMKfAjNfUuzECFRft/FNt/RugcZoL6YHjFckeoylnpt32jkqiOe6ZXrc9dGWRNSOh6ybJJY= X-Received: by 2002:a17:903:283:b0:186:897e:71ea with SMTP id j3-20020a170903028300b00186897e71eamr24767plr.123.1666973186931; Fri, 28 Oct 2022 09:06:26 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> <83lep0jspb.fsf@gnu.org> <83edusjhpe.fsf@gnu.org> In-Reply-To: From: Gustavo Barros Date: Fri, 28 Oct 2022 13:06:14 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Stefan Kangas Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Stefan, On Fri, 28 Oct 2022 at 12:26, Stefan Kangas wrote: > I get the same result. But I think this is expected, as the > `rename-file' docstring says: > > For NEWNAME to be recognized as a directory name, it should > end in a slash. > > So this function seems to be working as documented. Thanks for trying! I'm glad I'm not mad. :-) I had missed this bit of the docstring, and you're right, of course. So, it seems we are back to `move-file-to-trash', and how it calls `rename-file'. I've redefined `move-file-to-trash' to message `new-fn` right before `rename-file' is being called. And tested both: (move-file-to-trash "/path/to/orig/barbaz") (move-file-to-trash "/path/to/orig/barbaz/") And both cases output things like: Back to top level /home//.local/share/Trash/files/barbazOfwLav Entering debugger... Back to top level /home//.local/share/Trash/files/barbazVICScf Entering debugger... Back to top level /home//.local/share/Trash/files/barbazVd4241 Entering debugger... Back to top level /home//.local/share/Trash/files/barbaz04EjUm Entering debugger... Back to top level That is, no end slash appended to the directory at `move-file-to-trash'. So, it appears we have a good suspect. Why it works when the filesystem is the same still beats me. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 28 15:07:43 2022 Received: (at 58721) by debbugs.gnu.org; 28 Oct 2022 19:07:43 +0000 Received: from localhost ([127.0.0.1]:34290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooUhj-0001dn-4U for submit@debbugs.gnu.org; Fri, 28 Oct 2022 15:07:43 -0400 Received: from mail-pf1-f179.google.com ([209.85.210.179]:34692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooUhh-0001dT-9u for 58721@debbugs.gnu.org; Fri, 28 Oct 2022 15:07:41 -0400 Received: by mail-pf1-f179.google.com with SMTP id f140so5567834pfa.1 for <58721@debbugs.gnu.org>; Fri, 28 Oct 2022 12:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PRWeiuHWb/HMfBHgDGPv0WeDqg/kCRUgVbnpMQyx5+M=; b=Bb8csV2KkqdwT5kn4+vn7MsJVB9XviKYiFSdwLMSW2e4F6YcsEBZTW08gcQTFQMZ+u OKRFLveSjAqMfMOVcJ7NxD3ZX73NtajFrCNeZrKxV5+hL0xWHdBU109X+vvzzChEL1iU My+ICcSj2KfIsyOspnxD4lziGo2q7v2S8z1R/CR9ci2v6Z3QrJBgeSr3yZ9GShPuI9B0 c6tQFu7NVOmLQTDnbROnkhi0P4r/AIck0t+Gw8ZTCe6zQkUuhnEJy0bn0YDSbgY2UMSi 1NJf6btYsxME8ujOn+3eqm7196Xu3jE2+lB+QlCbT2iasFEnBX8mn2H77dJHWoYs9SpX TBSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PRWeiuHWb/HMfBHgDGPv0WeDqg/kCRUgVbnpMQyx5+M=; b=UdfVFwyVMUUFwNTTYIUhmmW6mH3HleurCmwfp4Bs/qDiuqrT38JfK8qR6Gf3zNxPHA Il8sGipoDjx7ijwoRJIfD/7TDVBtFvUqTnzJtQZdtr0u/zM/xrS4exEU8mJtpAgXMvMJ 6HKrASmNLVjib+ROamomNPqTUuIBt/FsmXBbmJj9qZ/+L6GpVQYe8ukqBfkmV3XtxGJe +h/QBEdFjEEzL0Y9iv7UlT7IDWA1i/ub/km3aqixx9LmpZ6cPcPcSKc/DeKhwTVR/77y mId4o8DhKMd5tEjYz7Jr6UbH7blCqXnEV5bK0ln421bm4Wj1koqj3L4xTq5f1Ba6mUAa Xf2Q== X-Gm-Message-State: ACrzQf1zAYk5Erbv3lCqChO2h23JJPH7r4Icb1IkU34f3PAxs82Dc2ax I/P7nw1WrP84orJ6SIQIDvsN4WUDHx2CpuCqRIY= X-Google-Smtp-Source: AMsMyM76gUTeZ1ZvSTNPwYNMMOXVBjP4CRG00H/WO6o6nUjJweMEtSldr2Vb8wVuS9A+rPCvS25dYg3k01zn+/aYHec= X-Received: by 2002:a63:84c2:0:b0:46e:f239:354c with SMTP id k185-20020a6384c2000000b0046ef239354cmr817945pgd.147.1666984055294; Fri, 28 Oct 2022 12:07:35 -0700 (PDT) MIME-Version: 1.0 References: <83r0ytl042.fsf@gnu.org> <83bkpxkwcd.fsf@gnu.org> <838rl1ku1b.fsf@gnu.org> <837d0lks02.fsf@gnu.org> <83lep0jspb.fsf@gnu.org> <83edusjhpe.fsf@gnu.org> In-Reply-To: From: Gustavo Barros Date: Fri, 28 Oct 2022 16:07:23 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Stefan Kangas Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Fri, 28 Oct 2022 at 13:06, Gustavo Barros wrote: > > I get the same result. But I think this is expected, as the > > `rename-file' docstring says: > > > > For NEWNAME to be recognized as a directory name, it should > > end in a slash. > > > > So this function seems to be working as documented. > That is, no end slash appended to the directory at > `move-file-to-trash'. So, it appears we have a good suspect. Why it > works when the filesystem is the same still beats me. Uhm, it is still not this. The previous sentence in the docstring you (Stefan) mentioned is: If NEWNAME is a directory name, rename FILE to a like-named file under NEWNAME. For NEWNAME to be recognized as a directory name, it should end in a slash. And, indeed, if we do: (rename-file "/path/to/orig/barbaz" "/path/to/dest/barbaz-foobar/" t) the operation succeeds, but the result is: /path/to/dest/barbaz-foobar/barbaz/zero.file And that's not what we want, or not what `move-file-to-trash' is trying to do. And that is precisely why it is passing the `ok-if-already-exists' as `t' there in the first place. In other words, as far as I can see, the sentence: For NEWNAME to be recognized as a directory name, it should end in a slash. should not imply that if `ok-if-already-exists' is `t' `rename-file' should fail to overwrite, whether the `newname' is a directory or not. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 01:25:28 2022 Received: (at 58721) by debbugs.gnu.org; 29 Oct 2022 05:25:28 +0000 Received: from localhost ([127.0.0.1]:34796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooeLX-0000pa-Om for submit@debbugs.gnu.org; Sat, 29 Oct 2022 01:25:28 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:47345 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooeLT-0000pP-Ka for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 01:25:27 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29T5PG8S061758 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Oct 2022 22:25:22 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Fri, 28 Oct 2022 14:44:29 +0300." <83edusjhpe.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <189663.1667021116.1@alto> Content-Transfer-Encoding: quoted-printable Date: Fri, 28 Oct 2022 22:25:16 -0700 Message-ID: <189664.1667021116@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, Gustavo Barros X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii wrote: > > From: Gustavo Barros [...] > > Can anyone else reproduce this, or is it really just me? > = > Yes, if someone else could reproduce, it could help. I can reproduce it (Emacs 28.2, Debian 11). I copied my ~/src/emacs-git tree to various directories and then tried trashing it. The failure only happened when trashing a tree that was on a separate filesystem from $HOME, and then it happened reliably. The type of filesystem that contained the copy didn't seem to matter--I saw the problem with both ext4 and vfat. My $HOME is ext4. When trashing a directory tree on the same filesystem, it's sufficient to rename the top-level directory into the trash hierarchy. But Unix doesn't support that across filesystems, so the directory tree needs to be copied into the trash hierarchy and then deleted at the original location. Since we see an empty directory after the error, I assume that something is going wrong with the copy phase. I set a breakpoint in #'copy-directory and got this stack: * copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/e= macs-gitH0l..." t nil) rename-file("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/emac= s-gitH0l..." t) move-file-to-trash("/tmp/emacs-git") delete-directory("/tmp/emacs-git" always t) dired-delete-file("/tmp/emacs-git" top t) dired-internal-do-deletions((("/tmp/emacs-git" . #>)) nil t) dired-do-flagged-delete() funcall-interactively(dired-do-flagged-delete) call-interactively(dired-do-flagged-delete nil nil) command-execute(dired-do-flagged-delete) The target directory (emacs-gitH0lx1e) already exists. In fact, it looks like the target directory already exists when #'rename-file is called. But I think that's expected. I clicked on the "..." in the backtrace to see whether the new name ends with a "/", and it does not. Hrm. Shouldn't the call to copy-directory look like copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/e= macs-gitH0l..." t nil t) ^^^ ? mike From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 06:36:07 2022 Received: (at 58721) by debbugs.gnu.org; 29 Oct 2022 10:36:07 +0000 Received: from localhost ([127.0.0.1]:35013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oojCB-0002en-5a for submit@debbugs.gnu.org; Sat, 29 Oct 2022 06:36:07 -0400 Received: from mail-pg1-f180.google.com ([209.85.215.180]:46974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oojC8-0002eF-Gl for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 06:36:06 -0400 Received: by mail-pg1-f180.google.com with SMTP id 78so6851085pgb.13 for <58721@debbugs.gnu.org>; Sat, 29 Oct 2022 03:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eeGctQpLKU8yTRA+YqijdcEXj2uhBUgXfo497MdZLDg=; b=l8yqbC/TbZuaIwsW0dtpC49OOn7lmeOpFC2D69FRPk+naWRGNfH3eBp0ILkuUyOG22 nAJlKiGGOOJfISsyEQDaDAV996pKwoQx3XTXDR2zzsdoawA5Nr6BbZWU6FE9tBDGWY1N N4mSmOk28jshE1eba3EtmJblbgkjY4a8UgQdFv5LQpmmL94foJGH2eUPqHUnZuL8fDNr jHxA6AmPhpHmZwXLlVEt8xKnY5s+HwHj8QBBoPUHlRv5BNGYOMjjetFDvKkMTkf9AoiQ KvJv4YhCxFHVE9PTSTiOnEBvfEPyT/RoDPCgBuy1lsbvlnmZOyhmBTnlKUejoJPIILx6 fR9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eeGctQpLKU8yTRA+YqijdcEXj2uhBUgXfo497MdZLDg=; b=JsfnszobxRcZNWr6JzGc6BfPzJIaNCPWSzL+2TOaRJ33eqE5WsBDhkMxdEGJ53+jvr jkE1pyG1wgZnuqAetVLb1Zu9G4eMV1t+PL4miLuV5jcCohPHSDRcgcFrrxLGmgwa5z6b CJXAwnOS9p7J/nNNnjac2fwrM2xe82bPFx2m8mu56E46CZ2wrX+V4lX7Tqg3FXbgFzuO hIvvD4TPYz3ZvOmpdc8gY8z3ZsVbxkZZMOx9ea/eBGsuf52w7Sv8xONrOz8JiuL88SKE xOjGhwKjo5L12BarItPAjm4VEl71E9GBy9lImNbPAsNqzSd/IrRqocI9lDRXT2S+T8Qt zg8g== X-Gm-Message-State: ACrzQf2K4uLFrV6ChMTxBEMYk6ekVBKur/W2VwS3azY5BCefH2n6oxUW ikJKxmwpzdlVUN2MAqEJpHeoZxsivEADz2xdiic= X-Google-Smtp-Source: AMsMyM4HRR2RubtPH8nCYveKhrFioJS4kkgqPCE4C8j5ZQSJvA4ZRg/fkOtd7WGUxO93rHI+BWaH1d8921V/dRL7lZs= X-Received: by 2002:a05:6a00:3249:b0:565:fc2c:ad79 with SMTP id bn9-20020a056a00324900b00565fc2cad79mr3803962pfb.72.1667039758499; Sat, 29 Oct 2022 03:35:58 -0700 (PDT) MIME-Version: 1.0 References: <83edusjhpe.fsf@gnu.org> <189664.1667021116@alto> In-Reply-To: <189664.1667021116@alto> From: Gustavo Barros Date: Sat, 29 Oct 2022 07:35:46 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Mike Kupfer Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hi Mike, On Sat, 29 Oct 2022 at 02:25, Mike Kupfer wrote: > I can reproduce it (Emacs 28.2, Debian 11). I copied my ~/src/emacs-git > tree to various directories and then tried trashing it. Thank you for testing! Gustavo. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 11:25:03 2022 Received: (at 58721) by debbugs.gnu.org; 29 Oct 2022 15:25:03 +0000 Received: from localhost ([127.0.0.1]:36363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oonhn-000411-DZ for submit@debbugs.gnu.org; Sat, 29 Oct 2022 11:25:03 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:19543 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oonhk-00040V-3R for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 11:25:02 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29TFOrwh024697 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 29 Oct 2022 08:24:58 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii , 58721@debbugs.gnu.org, Gustavo Barros Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: My message of "Fri, 28 Oct 2022 22:25:16 -0700." <189664.1667021116@alto> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6548.1667057093.1@alto> Content-Transfer-Encoding: quoted-printable Date: Sat, 29 Oct 2022 08:24:53 -0700 Message-ID: <6549.1667057093@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mike Kupfer wrote: > * copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files= /emacs-gitH0l..." t nil) > rename-file("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/em= acs-gitH0l..." t) > move-file-to-trash("/tmp/emacs-git") > delete-directory("/tmp/emacs-git" always t) > dired-delete-file("/tmp/emacs-git" top t) > dired-internal-do-deletions((("/tmp/emacs-git" . #>)) nil t) > dired-do-flagged-delete() > funcall-interactively(dired-do-flagged-delete) > call-interactively(dired-do-flagged-delete nil nil) > command-execute(dired-do-flagged-delete) [...] > Hrm. Shouldn't the call to copy-directory look like > = > copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files= /emacs-gitH0l..." t nil t) > ^^^ I played with this some more this morning, this time on Emacs 29. It looks like rename-file should have called copy-directory as copy-directory("/tmp/emacs-git" "/home/kupfer/.local/share/Trash/files/emacs-gitH0lx1e/" t nil t) That is, 2 changes from current behavior are needed: append a "/" to the target name, and specify copy-contents as t. The test case that I used to emulate the current behavior is 1. mkdir a; touch a/b 2. mkdir /tmp/newa (This assumes that /tmp is a different filesystem than the filesystem where "a" was created.) 3. M-: (copy-directory "a" "/tmp/newa" t nil) RET That gives the already-exists error. With (copy-directory "a" "/tmp/newa/" t nil), I get /tmp/newa/a/b, which isn't what's wanted for the Trash directory. With (copy-directory "a" "/tmp/newa/" t nil t), I get /tmp/newa/b, which is what's desired. mike From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 11:48:51 2022 Received: (at 58721) by debbugs.gnu.org; 29 Oct 2022 15:48:51 +0000 Received: from localhost ([127.0.0.1]:36405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooo4o-0006pv-Rq for submit@debbugs.gnu.org; Sat, 29 Oct 2022 11:48:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooo4l-0006pd-F6 for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 11:48:50 -0400 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 1ooo4g-0003ZT-71; Sat, 29 Oct 2022 11:48:42 -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=zHxrGBeFa3IIsYy2gLx/8LwUy4eR6b96COtkNOLIe0w=; b=PlxtgWY30fph mJf9ZuFkxHOHvn+iw1wiWlMstFItMGdSPwfbHZCsz2Zzdm7XES0gnSCgTirf0bobcXeUXD3rLJ/2W IuTi/w7sFLfqpx85x9fNXt2+Di/G4106MYhqi5Q1ljd1ND5fOV2nNamQa1rlVTJBIOPpQvmINbKxk V5p+ptBqDeGr0giPQZPBjuXQFGJl/KT8r8anBipD1tfb5W2EuiBBZ7hGGDRnM9eqC88kfGdFTRk/J NjaWbFd+axYEeyUlV4LJaxHEc1aDF2fDOt70GtZ5jhrOfOcy9o9EJQw1l/z/fKARWZVAA0Nmw9hh4 t4RIqOj6Z1p8lkIf0kvvyg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooo4f-0001by-J4; Sat, 29 Oct 2022 11:48:41 -0400 Date: Sat, 29 Oct 2022 18:48:35 +0300 Message-Id: <83mt9ehbqk.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <6549.1667057093@alto> (message from Mike Kupfer on Sat, 29 Oct 2022 08:24:53 -0700) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <6549.1667057093@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > Date: Sat, 29 Oct 2022 08:24:53 -0700 > > I played with this some more this morning, this time on Emacs 29. It > looks like rename-file should have called copy-directory as > > copy-directory("/tmp/emacs-git" > "/home/kupfer/.local/share/Trash/files/emacs-gitH0lx1e/" t nil t) I don't think we can change how rename-file behaves when the argument is a directory. Any changes we need to make must be in move-file-to-trash, not in primitives it calls. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 12:33:02 2022 Received: (at 58721) by debbugs.gnu.org; 29 Oct 2022 16:33:02 +0000 Received: from localhost ([127.0.0.1]:36471 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooola-0007yO-Eb for submit@debbugs.gnu.org; Sat, 29 Oct 2022 12:33:02 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:37659 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooolX-0007xw-H8 for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 12:33:00 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29TGWqXL033688 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 29 Oct 2022 09:32:57 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sat, 29 Oct 2022 18:48:35 +0300." <83mt9ehbqk.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11378.1667061172.1@alto> Date: Sat, 29 Oct 2022 09:32:52 -0700 Message-ID: <11379.1667061172@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii wrote: > > From: Mike Kupfer > > Date: Sat, 29 Oct 2022 08:24:53 -0700 > > > > I played with this some more this morning, this time on Emacs 29. It > > looks like rename-file should have called copy-directory as > > > > copy-directory("/tmp/emacs-git" > > "/home/kupfer/.local/share/Trash/files/emacs-gitH0lx1e/" t nil t) > > I don't think we can change how rename-file behaves when the argument > is a directory. Any changes we need to make must be in > move-file-to-trash, not in primitives it calls. Yes, that makes sense. So... (rename-file "a" "/tmp/newa" t) gives the original error. (rename-file "a" "/tmp/newa/" t) gives us /tmp/newa/a/b. What we want is /tmp/newa/b. I can think of 2 ways forward. One is to add an optional argument to rename-file to get the desired behavior, like the copy-contents argument to copy-directory. The other is for move-file-to-trash to call rename-file on the top-level contents of the directory that is being trashed ("a/b" in my simple test case), rather than on the directory itself. I think the first approach is preferable, in that it parallels the definition of copy-directory. But either should work. mike From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 12:56:50 2022 Received: (at 58721) by debbugs.gnu.org; 29 Oct 2022 16:56:50 +0000 Received: from localhost ([127.0.0.1]:36490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oop8c-00007g-FT for submit@debbugs.gnu.org; Sat, 29 Oct 2022 12:56:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oop8a-00007R-5n for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 12:56:49 -0400 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 1oop8U-0007mt-K8; Sat, 29 Oct 2022 12:56:42 -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=4D4kYQj+v1YCdnaXxqD+IaXJhlRQerUld87mBKQll8E=; b=gq1+D5j6WtQU cbjaWdNfVmZX5FnnE6DteIpZNcyKxqOCjNJTUO/4hKkYXnUqdZit1G6bNXxZkpCMxU85EZ6JPvTPR 4bqMeg+iRhwUcbUOKBQnURhvYg/W8yjfNfzNzE3qJlndbHCOM8lmDZ9jMV3441qn4LkYSiEQPa6ZN lgAgBVw+lTw2S0w9cYjuCiap9QBOlIC0jTOKLIna50N14Fd+eukvgIRsFq7gRqMkrlDhy+R6AReJl wGnZkr9zxlTs6v9lAR5gPebqNxAeDrTnURd/K+rQKHjziVrzuTCONXVK7mlSFgDhhAsle09CWEGU+ XOPsg6NuY9wHcOCCrWxHSw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oop8U-0001qf-2I; Sat, 29 Oct 2022 12:56:42 -0400 Date: Sat, 29 Oct 2022 19:56:35 +0300 Message-Id: <83eduqh8l8.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <11379.1667061172@alto> (message from Mike Kupfer on Sat, 29 Oct 2022 09:32:52 -0700) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <11379.1667061172@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com > Date: Sat, 29 Oct 2022 09:32:52 -0700 > > So... (rename-file "a" "/tmp/newa" t) gives the original error. > > (rename-file "a" "/tmp/newa/" t) gives us /tmp/newa/a/b. > > What we want is /tmp/newa/b. > > I can think of 2 ways forward. One is to add an optional argument to > rename-file to get the desired behavior, like the copy-contents argument > to copy-directory. > > The other is for move-file-to-trash to call rename-file on the top-level > contents of the directory that is being trashed ("a/b" in my simple test > case), rather than on the directory itself. > > I think the first approach is preferable, in that it parallels the > definition of copy-directory. But either should work. Yet another possibility is to refrain from calling rename-file when the moved file is a directory, and instead to do what rename-file does, with a twist, "by hand". That is what I actually prefer, as nothing is really wrong with rename-file. From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 20:09:19 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 00:09:19 +0000 Received: from localhost ([127.0.0.1]:36901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oovt9-00061k-EL for submit@debbugs.gnu.org; Sat, 29 Oct 2022 20:09:19 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:21401 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oovt4-00061Y-Bw for 58721@debbugs.gnu.org; Sat, 29 Oct 2022 20:09:18 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29U096sl088392 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 29 Oct 2022 17:09:12 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sat, 29 Oct 2022 19:56:35 +0300." <83eduqh8l8.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Sat, 29 Oct 2022 17:09:06 -0700 Message-ID: <32829.1667088546@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii wrote: > Yet another possibility is to refrain from calling rename-file when > the moved file is a directory, and instead to do what rename-file > does, with a twist, "by hand". That is what I actually prefer, as > nothing is really wrong with rename-file. I'm afraid I don't understand your suggestion. I've attached the proof-of-concept patch that I came up with, which just modifies move-file-to-trash. I've tested it with files and directories, both same-filesystem and crossing filesystems. Did you have in mind something similar? cheers, mike --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=bug58721.diffs Content-Description: proof-of-concept for fix diff --git a/lisp/files.el b/lisp/files.el index 1e1ec6127d..63786ec103 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -8565,10 +8565,29 @@ move-file-to-trash (setq files-base (substring (file-name-nondirectory info-fn) 0 (- (length ".trashinfo")))) (write-region nil nil info-fn nil 'quiet info-fn))) - ;; Finally, try to move the file to the trashcan. + ;; Finally, try to move the item to the trashcan. If + ;; it's a file, just move it. If it's a directory, + ;; there's no way to invoke rename-file to replace + ;; new-fn with fn, so move everything in fn and then + ;; delete it. (let ((delete-by-moving-to-trash nil) (new-fn (file-name-concat trash-files-dir files-base))) - (rename-file fn new-fn overwrite))))))))) + (if (not (file-directory-p fn)) + (rename-file fn new-fn overwrite) + (make-directory new-fn) + (mapc + (lambda (f1) + (let ((src (file-name-concat fn f1)) + (targ (file-name-concat new-fn f1))) + (cond + ((or (string= f1 ".") + (string= f1 "..")) + t) + (t + (rename-file src targ))))) + (directory-files fn)) + (delete-directory fn)))))))))) + (defsubst file-attribute-type (attributes) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 02:41:27 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 06:41:27 +0000 Received: from localhost ([127.0.0.1]:37186 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1op20c-00084x-Mj for submit@debbugs.gnu.org; Sun, 30 Oct 2022 02:41:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1op20a-00084i-3p for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 02:41:25 -0400 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 1op20U-0004JJ-Km; Sun, 30 Oct 2022 02:41:18 -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=0LKsNMxeT0Y1Nm5PTTMm4Ia2VA24dEfCrBMadTJdwXU=; b=fJnY8uufOxmY 13YfmvQBg6kDFtvoMhat/NEDx6hr+ERXalYR02zPsGCqolJo+k/5YOt1TvDcqNQ4UNxG+lT63Go9h Zn2+QTnRH77YQbnD9zxlVucZLemM40GSUS2nb15RoUL/2B/h9U7GMZsVooDUr5YDn/PB0w5PNX8MV nSxzyX0yqXgXs8yGOqIEdfBWhYRylvLs5j9WFkZqjh3BzELkyr0Rs+854FtpQbXicIR/AzAIWJ1Ku 8O2Uvr85sIPbYpb7QJj+9KkGFQRHvEgdqPSS0g4E93MNUA2HQCMqMrcK4JaeyVlBnfTCxDocEazAI gWaPzORmeEuWwp4XCpGiNg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1op20T-0004ht-Vl; Sun, 30 Oct 2022 02:41:18 -0400 Date: Sun, 30 Oct 2022 08:41:00 +0200 Message-Id: <8335b5hkzn.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <32829.1667088546@alto> (message from Mike Kupfer on Sat, 29 Oct 2022 17:09:06 -0700) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <32829.1667088546@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com > Date: Sat, 29 Oct 2022 17:09:06 -0700 > > Eli Zaretskii wrote: > > > Yet another possibility is to refrain from calling rename-file when > > the moved file is a directory, and instead to do what rename-file > > does, with a twist, "by hand". That is what I actually prefer, as > > nothing is really wrong with rename-file. > > I'm afraid I don't understand your suggestion. > > I've attached the proof-of-concept patch that I came up with, which just > modifies move-file-to-trash. I've tested it with files and directories, > both same-filesystem and crossing filesystems. Did you have in mind > something similar? Yes, thanks. I just thought you'd be able to call copy-directory, similarly (but differently) to what rename-file does, instead of using your lambda-function. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 13:40:34 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 17:40:34 +0000 Received: from localhost ([127.0.0.1]:38989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opCIT-00035W-M5 for submit@debbugs.gnu.org; Sun, 30 Oct 2022 13:40:33 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:63298 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opCIR-00035M-WA for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 13:40:33 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29UHeOo9014772 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 30 Oct 2022 10:40:30 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sun, 30 Oct 2022 08:41:00 +0200." <8335b5hkzn.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Sun, 30 Oct 2022 10:40:24 -0700 Message-ID: <17965.1667151624@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii wrote: > I just thought you'd be able to call copy-directory, similarly (but > differently) to what rename-file does, instead of using your > lambda-function. Ah, of course. Thanks, yes, that's cleaner. How does the attached patch look? mike --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-cross-filesystem-directory-trashing-Bug-58721.patch Content-Description: proposed patch >From e8fdbeb44dbea9ebf5679c23bf3ad5c5a61141ec Mon Sep 17 00:00:00 2001 From: Mike Kupfer Date: Sun, 30 Oct 2022 10:31:11 -0700 Subject: [PATCH] Fix cross-filesystem directory trashing (Bug#58721) * lisp/files.el (move-file-to-trash): When trashing a directory, copy it into the trash folder and then delete it, rather than using rename-file. --- lisp/files.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 1e1ec6127d..b347815314 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -8565,10 +8565,20 @@ move-file-to-trash (setq files-base (substring (file-name-nondirectory info-fn) 0 (- (length ".trashinfo")))) (write-region nil nil info-fn nil 'quiet info-fn))) - ;; Finally, try to move the file to the trashcan. + ;; Finally, try to move the item to the trashcan. If + ;; it's a file, just move it. If it's a directory, + ;; rename-file will not work across filesystems, so + ;; copy the directory tree and then delete it. (let ((delete-by-moving-to-trash nil) (new-fn (file-name-concat trash-files-dir files-base))) - (rename-file fn new-fn overwrite))))))))) + (if (not (file-directory-p fn)) + (rename-file fn new-fn overwrite) + (make-directory new-fn) + (copy-directory fn + (file-name-as-directory new-fn) + t nil t) + (delete-directory fn t)))))))))) + (defsubst file-attribute-type (attributes) -- 2.30.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 14:03:21 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 18:03:21 +0000 Received: from localhost ([127.0.0.1]:38998 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opCeX-0003gF-5e for submit@debbugs.gnu.org; Sun, 30 Oct 2022 14:03:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opCeU-0003g0-Vy for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 14:03:19 -0400 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 1opCeP-0002cP-BW; Sun, 30 Oct 2022 14:03:13 -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=R5ERU2j1a/tVO09FxLm7xVLyiz1Zl2lfpYmgm5SDEls=; b=Uu88DO576/2r E+IHrfg2qmUWOVoJKTaojzM58fpLU2w5ol4LhGPvsLG26BSjWp5A4pA8GQGAkNRP/FjrFccSONMo0 x7c6TCuOKsARBNNK/hSsds74U1HP7xdBLq7GNTcd2ukRpOfsZ9R+uygiZCjC0htW73aqPwr+Mww3x KUh4ggVYD9KXkw6ecRzE3/CSPZcJIQ6iBnAyYHdY4VaqXue7b74JpvSp01nfUZmG4ERctfezxFzjD HJCRZZ+q/YOQl6beOv54NLP3k2fJbbEPksjpwQdkZiMqGDIEqcn3n6kYD8Axw79CpKABu8BS1wFTY KvRloIn+HIa9xXJ1HXMqgQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opCeO-0006Sh-P7; Sun, 30 Oct 2022 14:03:13 -0400 Date: Sun, 30 Oct 2022 20:02:54 +0200 Message-Id: <837d0hfaup.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <17965.1667151624@alto> (message from Mike Kupfer on Sun, 30 Oct 2022 10:40:24 -0700) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <17965.1667151624@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com > Date: Sun, 30 Oct 2022 10:40:24 -0700 > > Eli Zaretskii wrote: > > > I just thought you'd be able to call copy-directory, similarly (but > > differently) to what rename-file does, instead of using your > > lambda-function. > > Ah, of course. Thanks, yes, that's cleaner. How does the attached > patch look? Looks good, but maybe add to the comment the reason _why_ we don't use rename-file for directories. You explained _what_ we do, but not _why_. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 14:18:38 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 18:18:39 +0000 Received: from localhost ([127.0.0.1]:39003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opCtK-000424-Nz for submit@debbugs.gnu.org; Sun, 30 Oct 2022 14:18:38 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:32999 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opCtI-00041t-IM for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 14:18:37 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29UIIT9h019663 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 30 Oct 2022 11:18:34 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sun, 30 Oct 2022 20:02:54 +0200." <837d0hfaup.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21141.1667153909.1@alto> Date: Sun, 30 Oct 2022 11:18:29 -0700 Message-ID: <21142.1667153909@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii wrote: > Looks good, but maybe add to the comment the reason _why_ we don't use > rename-file for directories. You explained _what_ we do, but not > _why_. Do you mean something like -----8<-----8<----- Fix cross-filesystem directory trashing (Bug#58721) * lisp/files.el (move-file-to-trash): When trashing a directory, copy it into the trash folder and then delete it, rather than using rename-file. rename-file can only be used when the to-be-trashed directory and the trashcan live in the same filesystem; this approach handles both that case and the different-filesystem case. ----->8----->8----- ? mike From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 15:51:43 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 19:51:43 +0000 Received: from localhost ([127.0.0.1]:39050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opELO-0006Ka-Lw for submit@debbugs.gnu.org; Sun, 30 Oct 2022 15:51:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opELN-0006KO-0q for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 15:51:41 -0400 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 1opELH-0005YP-HN; Sun, 30 Oct 2022 15:51:35 -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=+3CXURpunwrZILk+xUykqFWRTk/evCjS4lhAYZpyOPM=; b=a6liTHbfJ+jF 3NMRmim0rwa2nfVooHlsS/mJtFA4oZWm9ItUCZd6d15w+uPAVbP/j5H5tWw6J0EjVZ3d01oNMCbYm WXIQBGwjrhDsmxJy1YlGCA3dIbq0u+MPZAccgXM9FZx2CqDWoKTkGT0PooBdF2+Rz/Kqsu7fs22B5 zdIyDeaLXy7pleA81JulVdEvWj4EhLoMnFjqfweB5zP/5GsYhmIO4u9frJ5JCvVm75lqX8Wbyc1iW XiehZmOrIoCeu9Np2bMrdFWtrSTHRBRAUfSK7CPLq3yYBYaR6Jp7jH81jdX+7mDippZQxnQdEZmRZ gvBlobUVwVq0qYQRyNqMvg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opELH-0005zm-0X; Sun, 30 Oct 2022 15:51:35 -0400 Date: Sun, 30 Oct 2022 21:51:18 +0200 Message-Id: <835yg1f5u1.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <21142.1667153909@alto> (message from Mike Kupfer on Sun, 30 Oct 2022 11:18:29 -0700) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <21142.1667153909@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com > Date: Sun, 30 Oct 2022 11:18:29 -0700 > > Eli Zaretskii wrote: > > > Looks good, but maybe add to the comment the reason _why_ we don't use > > rename-file for directories. You explained _what_ we do, but not > > _why_. > > Do you mean something like > > -----8<-----8<----- > Fix cross-filesystem directory trashing (Bug#58721) > > * lisp/files.el (move-file-to-trash): When trashing a directory, > copy it into the trash folder and then delete it, rather than > using rename-file. rename-file can only be used when the > to-be-trashed directory and the trashcan live in the same filesystem; > this approach handles both that case and the different-filesystem case. > ----->8----->8----- I meant in the code, not the log message, and I meant to tell more detail. But never mind, I can always add it later myself. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 18:20:15 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 22:20:16 +0000 Received: from localhost ([127.0.0.1]:39152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opGf9-0001bs-JI for submit@debbugs.gnu.org; Sun, 30 Oct 2022 18:20:15 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:64439 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opGf7-0001bg-40 for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 18:20:13 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29UMK5XO048144 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 30 Oct 2022 15:20:10 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sun, 30 Oct 2022 21:51:18 +0200." <835yg1f5u1.fsf@gnu.org> X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Sun, 30 Oct 2022 15:20:05 -0700 Message-ID: <50290.1667168405@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii wrote: > I meant in the code, not the log message, and I meant to tell more > detail. > > But never mind, I can always add it later myself. Well, it turns out I hadn't tested my previous patch enough. It handled the first deletion of directory foo, but not subsequent deletions (which was the entire point of the fix, sigh). I've attached another patch. I took a stab at improving the commenting in the code while I was there. mike --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-cross-filesystem-directory-trashing-Bug-58721.patch Content-Description: v2 fix >From 402c7c819dbe2a1cd96462be699ae2af1f5c2440 Mon Sep 17 00:00:00 2001 From: Mike Kupfer Date: Sun, 30 Oct 2022 10:31:11 -0700 Subject: [PATCH] Fix cross-filesystem directory trashing (Bug#58721) * lisp/files.el (move-file-to-trash): When trashing a directory with the same name as something that's already in the trash, copy it into the trash folder and then delete it, rather than using rename-file. --- lisp/files.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 1e1ec6127d..6bfb3aa738 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -8565,10 +8565,27 @@ move-file-to-trash (setq files-base (substring (file-name-nondirectory info-fn) 0 (- (length ".trashinfo")))) (write-region nil nil info-fn nil 'quiet info-fn))) - ;; Finally, try to move the file to the trashcan. + ;; Finally, try to move the item to the trashcan. If + ;; it's a file, just move it. Things are more + ;; complicated for directories. If the target + ;; directory already exists (due to uniquification) + ;; and the trash directory is in a different + ;; filesystem, rename-file will error out, even when + ;; 'overwrite' is non-nil. Rather than worry about + ;; whether we're crossing filesystems, just check if + ;; we've moving a directory and the target directory + ;; already exists. That handles both the + ;; same-filesystem and cross-filesystem cases. (let ((delete-by-moving-to-trash nil) (new-fn (file-name-concat trash-files-dir files-base))) - (rename-file fn new-fn overwrite))))))))) + (if (or (not is-directory) + (not (file-exists-p new-fn))) + (rename-file fn new-fn overwrite) + (copy-directory fn + (file-name-as-directory new-fn) + t nil t) + (delete-directory fn t)))))))))) + (defsubst file-attribute-type (attributes) -- 2.30.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 19:10:23 2022 Received: (at 58721) by debbugs.gnu.org; 30 Oct 2022 23:10:23 +0000 Received: from localhost ([127.0.0.1]:39211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opHRf-0002rf-6y for submit@debbugs.gnu.org; Sun, 30 Oct 2022 19:10:23 -0400 Received: from mail-pg1-f182.google.com ([209.85.215.182]:39724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opHRe-0002rT-Cv for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 19:10:22 -0400 Received: by mail-pg1-f182.google.com with SMTP id b5so9293963pgb.6 for <58721@debbugs.gnu.org>; Sun, 30 Oct 2022 16:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zYir0UH9BW/QGeDK3KM1nAs1X7bWhGCINAaDOm6kELs=; b=KSKHdJM+U8tKcyjE8QPT1dwQHpNY+gdvUIjsH1a3Af4VGljaW3kolOQ/2YN/Lkt/Gm E2PIjRlhOFtMbaXHAAehaeeVmX6txHOtzcB5rh7CYCc0zUbI9WkJlrshXf1Vgqfe9aKq zvPychOpATKglgZZ+tz7u43qJwMK3YqiE9AqTuob3uG7Sora9rnsJetpZIe/U6mL0qUX TOJBIU+LsS37XLZUGpXw8BbBY7UUhxiNWeZdE415oUzfVuH5b3UdAf+EhVp7BYZwNYWd zMOsfLN8XWdRuopkv7wsJAMbYhUFdGTtwBbnaFJRsPEduksp6ho1lOvamDbSyw9mm+Ey uEjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zYir0UH9BW/QGeDK3KM1nAs1X7bWhGCINAaDOm6kELs=; b=pvL4MqXANNa+TxQZh0TtjOq9fVh+i6KxA0i7QjpPYeysirVUN3cwy1KDZ//NUlJZDa 7dDzgHRdioVmEEZhXsa+rKplfeg5fW4TzYQ4qOd+5fk+HEgWVik/ns6Vo4HUQCrKGdZg sV3vDkWGNKmw14qV7fUbOM0OBNsD5F77kHm7i7sEpOAG46rN1LyNhGCEH2G4H2duNrlU 3iNI5o7gOI2ao6sl7D9CZR5h6wOliECq8M+pWDALEYIy94Ts+0w2x6CRTxWt8TArR5VV eMbRdMp6aK0ZHX/p/FcyziNmzH5ILDQBPqHqdliF8M3kOlp7FcACY78MAPb89VptnDo7 LYIw== X-Gm-Message-State: ACrzQf2wrSXk7f2oZSjUoVyMlyHAGePJYiBR/BvtaQnB7YSA/4zmbgGk 27CzV8Eh49qmhRYxp+5dpAuZKseL7seAkgpIySo= X-Google-Smtp-Source: AMsMyM4pKGLN1rmuDk+tM3+oP8VZN8nBt3SPnsYSKSzJDGNkH46T+osUxACJiIAQo3QGziA8zWANzAVZQqc4FyAX2rk= X-Received: by 2002:a05:6a00:a21:b0:562:99d6:c30a with SMTP id p33-20020a056a000a2100b0056299d6c30amr11021177pfh.35.1667171416400; Sun, 30 Oct 2022 16:10:16 -0700 (PDT) MIME-Version: 1.0 References: <835yg1f5u1.fsf@gnu.org> <50290.1667168405@alto> In-Reply-To: <50290.1667168405@alto> From: Gustavo Barros Date: Sun, 30 Oct 2022 20:10:04 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Mike Kupfer Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Sun, 30 Oct 2022 at 19:20, Mike Kupfer wrote: > Well, it turns out I hadn't tested my previous patch enough. It handled > the first deletion of directory foo, but not subsequent deletions (which > was the entire point of the fix, sigh). I've attached another patch. > I took a stab at improving the commenting in the code while I was > there. I may be wrong but, as far as my reading goes, I think this might misbehave if the "directory" is a symlink. `is-directory' is built as `(file-directory-p fn)' which returns t even if it is a symlink to a directory. Would things such as `copy-directory` (with `copy-contents` arg t) and `delete-directory' work just as well in such a case? Besides that, in general, imho I cannot think of this issue as something else other than a misbehavior of `rename-file', so that the patch in these terms feels like a workaround. I understand Eli disagrees. True, most likely this is just a muggle (me) being naive, so I'll try to watch and learn. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 20:01:52 2022 Received: (at 58721) by debbugs.gnu.org; 31 Oct 2022 00:01:52 +0000 Received: from localhost ([127.0.0.1]:39231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opIFT-00046g-Pm for submit@debbugs.gnu.org; Sun, 30 Oct 2022 20:01:52 -0400 Received: from shell1.rawbw.com ([198.144.192.42]:49988 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opIFQ-00046W-To for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 20:01:49 -0400 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 29V01f3h058462 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 30 Oct 2022 17:01:46 -0700 (PDT) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Gustavo Barros Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sun, 30 Oct 2022 20:10:04 -0300." X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <58148.1667174501.1@alto> Date: Sun, 30 Oct 2022 17:01:41 -0700 Message-ID: <58149.1667174501@alto> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Gustavo Barros wrote: > I may be wrong but, as far as my reading goes, I think this might > misbehave if the "directory" is a symlink. `is-directory' is built as > `(file-directory-p fn)' which returns t even if it is a symlink to a > directory. Good point, thanks. I think this points out a pre-existing issue with move-file-to-trash, in that the code to create a unique trash name will create a directory, rather than a file. > Besides that, in general, imho I cannot think of this issue as > something else other than a misbehavior of `rename-file', so that the > patch in these terms feels like a workaround. I agree that it's an inconsistency in the behavior of rename-file. If the thing being renamed is a file, the target gets replaced, whether or not we're crossing filesystems. But if it's a directory, the target gets replaced if it's in the same filesystem, but it's an error if the target is in a different filesystem. If I understand Eli's concern, it's a question of whether making the behavior more consistent is worth the risk that it would break existing code--code that could assume the current behavior. I'd like to resolve the symlink behavior before pushing any fix. But I've been feeling increasingly unwell as the day has progressed, so I think I'll stop work on this bug until I'm feeling better. mike From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 30 20:23:40 2022 Received: (at 58721) by debbugs.gnu.org; 31 Oct 2022 00:23:40 +0000 Received: from localhost ([127.0.0.1]:39259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opIaZ-0004ci-Vx for submit@debbugs.gnu.org; Sun, 30 Oct 2022 20:23:40 -0400 Received: from mail-pf1-f173.google.com ([209.85.210.173]:35611) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opIaX-0004cS-9c for 58721@debbugs.gnu.org; Sun, 30 Oct 2022 20:23:38 -0400 Received: by mail-pf1-f173.google.com with SMTP id k15so1282276pfg.2 for <58721@debbugs.gnu.org>; Sun, 30 Oct 2022 17:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YxnVqzYkFkYs4RXE7N3tPH+e3Oi/K8Srvc6zNoGXiTA=; b=nH8FTuzmjRdQx8asWFO8eqbtevBc07xqje7SaOnQuxLxCjU9FDm4yS0lQ+iSnYq6mI yeoH5RbIVJeD7Ya3JUFIRf7xWZAK40f02Z8fbqqUVwgJNC6IfrD7MAQniu+Im4ecebRf 7g5Y924kqmGleFde3laLfBIowDujh/u8z7wOKJhluDq8pgQNqVeschvTML931/+gvHlr +d0aJOG+T3CkgqstlGBGXhXlMfyoR+i4yTh9xorvo2pLEa+nGYC4S5nwR5XbvLkKiS7/ toG/lT9hXjLkYrD2mv33ISZZ2v39SlJBHnCbW33cL2FLEuT8OdsBWDJ7nwh0SIpA/4m1 u6nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YxnVqzYkFkYs4RXE7N3tPH+e3Oi/K8Srvc6zNoGXiTA=; b=1RQDrhGQaxgILvmJaaIKqG6TeUJFQR39sWkFf/oMAdmaVhZivD3uXaXGnhI7r4WN/O S4ymunOOmuXMVt1G/s+BcBMw8J/jOGbZ83N+pRLDOW55JMX/T8/y5YYfVCQvNMr2y9tH buc2ioQKiQ9yH1Jfa+x/3sQWU3UdY+j2tFsPGcF6NsLK532Qh9Dz+irGzGrOs/pgPKC8 5ZVFWewrgTI3m2uLxVDf+HOmyMIRMwW7q8Lz9dG5eyJB9aS1NM7MeWFvJ83mVLmFPTT+ k/haCX/mm51oJ2gSPMhbKYzidhvpKA/aX33LxGEglbp4C6mugit1WN/eIETdnhO+apja wmtA== X-Gm-Message-State: ACrzQf2QJiOhZP52TRIYUWWKQrlbpB3M5tZAYN3lL/jV0MIhHWuJjjS0 Grpepoamxlt/I3jdT5+p1zmS9O1E4kMeXbZX/FE= X-Google-Smtp-Source: AMsMyM7EWRZSdInud1cmOc+vHzDtr+BYyO0USf3JV5t59Nc4PkQfcZNNQFKEP2uiEVc/3ZljnxhtjuA46qsU4x9VQKA= X-Received: by 2002:a05:6a00:1a44:b0:52a:ecd5:bbef with SMTP id h4-20020a056a001a4400b0052aecd5bbefmr11341594pfv.28.1667175810506; Sun, 30 Oct 2022 17:23:30 -0700 (PDT) MIME-Version: 1.0 References: <58149.1667174501@alto> In-Reply-To: <58149.1667174501@alto> From: Gustavo Barros Date: Sun, 30 Oct 2022 21:23:18 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Mike Kupfer Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Sun, 30 Oct 2022 at 21:01, Mike Kupfer wrote: > Good point, thanks. I think this points out a pre-existing issue with > move-file-to-trash, in that the code to create a unique trash name will > create a directory, rather than a file. I agree, I also think that there was a pre-existing inconsistency there, but `rename-file` would cover it up later on. But trying to do it manually, complicates things in this regard as well. > I agree that it's an inconsistency in the behavior of rename-file. If > the thing being renamed is a file, the target gets replaced, whether or > not we're crossing filesystems. But if it's a directory, the target > gets replaced if it's in the same filesystem, but it's an error if the > target is in a different filesystem. If I understand Eli's concern, > it's a question of whether making the behavior more consistent is worth > the risk that it would break existing code--code that could assume the > current behavior. I understand that concern too. But we don't even understand well (as far as I can see) why it fails when crossing filesystems, and are already rushing to a workaround. I just offered some respectful resistance. And if, after all, the decision is not to touch `rename-file' because it's risky, so that a workaround is really what is intended, I'll get that. > I'd like to resolve the symlink behavior before pushing any fix. But > I've been feeling increasingly unwell as the day has progressed, so I > think I'll stop work on this bug until I'm feeling better. Get well soon! :-) From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 08:49:32 2022 Received: (at 58721) by debbugs.gnu.org; 31 Oct 2022 12:49:32 +0000 Received: from localhost ([127.0.0.1]:39732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opUEO-0004zD-9j for submit@debbugs.gnu.org; Mon, 31 Oct 2022 08:49:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opUEM-0004z1-DK for 58721@debbugs.gnu.org; Mon, 31 Oct 2022 08:49:31 -0400 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 1opUEG-0001Ub-Il; Mon, 31 Oct 2022 08:49:25 -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=K2Vo6LwAk/qxMpKxeRhyQSQ/jAW2lSkYufcB+38b67w=; b=GiJ6vN+YNjXU vlNvQQMQPLQnMc9694EMIiUitjus5pQzgJ6cN/3MB3fOZb/vPBHI1iYf4ZIxqo4aZ6bUcc2lEwpRk IUrPFmncvkBENwrtQEguJka0WF7+Wr1XuAYRSbWrpUmGlWJTdT3Ly4uV3PL/yZZUhFMdN9HCuiEhB eS/6LeSTB1HdqGhq8WPilFnaTvrS1CuGQpn1lQSh40C29/oO2fOftez5kEQEzIajL/MS5YFwuiFzP tGmzf+yRBCWlEqwBYulDZt1mRsYR1IHFpF/rXTdnjADMNCtuL7py0QwF8R2ItIHA+BFjMY3fRgzFC CNKJkk/NRKWP/xLchL6/sQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opUEF-0003ox-Si; Mon, 31 Oct 2022 08:49:24 -0400 Date: Mon, 31 Oct 2022 14:49:08 +0200 Message-Id: <83y1swdupn.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <58149.1667174501@alto> (message from Mike Kupfer on Sun, 30 Oct 2022 17:01:41 -0700) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <58149.1667174501@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > cc: Eli Zaretskii , 58721@debbugs.gnu.org > Date: Sun, 30 Oct 2022 17:01:41 -0700 > > Gustavo Barros wrote: > > > I may be wrong but, as far as my reading goes, I think this might > > misbehave if the "directory" is a symlink. `is-directory' is built as > > `(file-directory-p fn)' which returns t even if it is a symlink to a > > directory. > > Good point, thanks. I think this points out a pre-existing issue with > move-file-to-trash, in that the code to create a unique trash name will > create a directory, rather than a file. What is the expected semantics of moving a symlink to trashcan? Is it supposed to move the symlink or its target? (I'd think it's the former, but maybe my instincts are wrong.) If the expectations are that the symlink is moved, then all we need to do is to treat symlinks as regular files, by augmenting file-directory-p not to dupe us. > > Besides that, in general, imho I cannot think of this issue as > > something else other than a misbehavior of `rename-file', so that the > > patch in these terms feels like a workaround. > > I agree that it's an inconsistency in the behavior of rename-file. If > the thing being renamed is a file, the target gets replaced, whether or > not we're crossing filesystems. But if it's a directory, the target > gets replaced if it's in the same filesystem, but it's an error if the > target is in a different filesystem. If I understand Eli's concern, > it's a question of whether making the behavior more consistent is worth > the risk that it would break existing code--code that could assume the > current behavior. I'm okay with filing another bug report about rename-file, and discussing this there. But that's a separate issue, and fix of this bug should not depend on that. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 31 09:17:08 2022 Received: (at 58721) by debbugs.gnu.org; 31 Oct 2022 13:17:08 +0000 Received: from localhost ([127.0.0.1]:39768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opUf5-0007qp-QP for submit@debbugs.gnu.org; Mon, 31 Oct 2022 09:17:08 -0400 Received: from mail-pj1-f51.google.com ([209.85.216.51]:43990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opUf3-0007qH-H4 for 58721@debbugs.gnu.org; Mon, 31 Oct 2022 09:17:06 -0400 Received: by mail-pj1-f51.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso10262904pjc.2 for <58721@debbugs.gnu.org>; Mon, 31 Oct 2022 06:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RbgbqhnIQXglE5jHUWI5E/HN7dBMPHqsUn0iZWu5JVk=; b=YsyIzrFhSCiy9YLlK/fwzeEB2MrFIymyWuY68rb7lOrdFAqKKzj/oP2L5XCZHg9H8L hr+S3y6nbO79RNlf8pcT6SQfabjmLT1gVp7bDI2kXRPck+BWt1U91nSMmBzaaK9HCmrV tM8b/QLCnaVeEyfAkIqClSZFXdAPKvL2fAJMDxB+qufDG9nZQzn4tsSqqbXnnoh0CvJ0 i2/zO6cTtraobE77XA7wTzfSHdAIE56O1m1pCJ/80THNgaK3C+QavFaOr/q27vbkUrB+ taA8ufLnv5Ddy8q9gYMY2/I0XQqMlMhDlqJ4B/mCVYhVHiUuF2xhGueQlnpTxYa9tcpg Fmzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RbgbqhnIQXglE5jHUWI5E/HN7dBMPHqsUn0iZWu5JVk=; b=jC17nBIuWQ0r8DnnORw+NR7gG6j6JWt+LnFD2wV4Ikhsy5AiZ5xqOhDsFyzyIQU/mt ZaPZxSYvaLLjqC4jqkYGkZMqh8Sc+btnCp93Xxnu8d9EbE8cCysUsuBqFjbcZPdAr9TB dBL0W36/iKc5hF++3Hbq9rH3BihN0K/tUer5SQ0GqodQk4VOSYuwmt+P6IfteQXTnY4H rq8++f8Ep5Ad1wZ8wdRbbMif+FuzAL6S1XmUf8KGybR2Q7uhQFNPZPKO6MTKO2jfr5qs zFTlRDSbGlVWaQg0LvAQKa8TVDnpiH2govLPcqGK11sMiot0FZpylChI5NiRoVx/F6b/ Am5Q== X-Gm-Message-State: ACrzQf1l7vFC5MwPZwL63wzZhi1f6LeHYhhiWa0QkjWH9lBjlkIcyBz+ cXVcg10jKAzbivKT0ZQJtRnBMbEplOUwrbZKB0c= X-Google-Smtp-Source: AMsMyM5p1l2O47g6QF+L3kOtoHWic0dzPox4/mXInuEcsTw6n0pPqzXebA9ZzLX3XJF9azgjSf13MTMPcBqx5Wd8vA4= X-Received: by 2002:a17:90a:8a8c:b0:213:c06c:7003 with SMTP id x12-20020a17090a8a8c00b00213c06c7003mr10737178pjn.147.1667222219576; Mon, 31 Oct 2022 06:16:59 -0700 (PDT) MIME-Version: 1.0 References: <58149.1667174501@alto> <83y1swdupn.fsf@gnu.org> In-Reply-To: <83y1swdupn.fsf@gnu.org> From: Gustavo Barros Date: Mon, 31 Oct 2022 10:16:47 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org, Mike Kupfer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Mon, 31 Oct 2022 at 09:49, Eli Zaretskii wrote: > What is the expected semantics of moving a symlink to trashcan? Is it > supposed to move the symlink or its target? (I'd think it's the > former, but maybe my instincts are wrong.) If the expectations are > that the symlink is moved, then all we need to do is to treat symlinks > as regular files, by augmenting file-directory-p not to dupe us. I'm not sure either, but my instincts are the same as yours. If that's any reference, I just tested here, and that's what "gio trash" does (moves the symlink, not the target). > I'm okay with filing another bug report about rename-file, and > discussing this there. But that's a separate issue, and fix of this > bug should not depend on that. Understood. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 20 20:08:31 2022 Received: (at 58721) by debbugs.gnu.org; 21 Nov 2022 01:08:31 +0000 Received: from localhost ([127.0.0.1]:44940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvIV-0001pG-6P for submit@debbugs.gnu.org; Sun, 20 Nov 2022 20:08:31 -0500 Received: from shell1.rawbw.com ([198.144.192.42]:64815 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvIP-0001p3-OE for 58721@debbugs.gnu.org; Sun, 20 Nov 2022 20:08:29 -0500 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 2AL18IvA090311 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 20 Nov 2022 17:08:23 -0800 (PST) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Gustavo Barros , Eli Zaretskii Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Mon, 31 Oct 2022 10:16:47 -0300." X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Sun, 20 Nov 2022 17:08:18 -0800 Message-ID: <66176.1668992898@alto> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Gustavo Barros wrote: > On Mon, 31 Oct 2022 at 09:49, Eli Zaretskii wrote: > > > What is the expected semantics of moving a symlink to trashcan? Is it > > supposed to move the symlink or its target? (I'd think it's the > > former, but maybe my instincts are wrong.) If the expectations are > > that the symlink is moved, then all we need to do is to treat symlinks > > as regular files, by augmenting file-directory-p not to dupe us. > > I'm not sure either, but my instincts are the same as yours. If that's > any reference, I just tested here, and that's what "gio trash" does > (moves the symlink, not the target). Yes, I tried a few graphical file browsers (Thunar, Caja, and Dolphin), and they all move the symlink, not the target, to Trash. After getting my test setup straightened out, I think I have a fix for the symlink issue and for the issue that Gustavo originally reported (cross-filesystem trashing fails when there's already a directory with the same name in Trash). I've committed these fixes separately; see attached. Gustavo, can you try these out and make sure they handle your use case(s)? > > I'm okay with filing another bug report about rename-file, and > > discussing this there. But that's a separate issue, and fix of this > > bug should not depend on that. > > Understood. Okay. I'm not planning to follow up on this, Gustavo, so if you'd like to lobby for a change to rename-file, you'll need to open a bug for it (if you haven't already). cheers, mike --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-cross-filesystem-directory-trashing-Bug-58721.patch Content-Description: fix duplicate trashing >From f749a1dd7875a83e6415d8c512c5659f0f23c834 Mon Sep 17 00:00:00 2001 From: Mike Kupfer Date: Sun, 30 Oct 2022 10:31:11 -0700 Subject: [PATCH 1/2] Fix cross-filesystem directory trashing (Bug#58721) * lisp/files.el (move-file-to-trash): When trashing a directory with the same name as something that's already in the trash, copy it into the trash folder and then delete it, rather than using rename-file. --- lisp/files.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index a2825322580..de4f68ebd51 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -8596,10 +8596,27 @@ move-file-to-trash (setq files-base (substring (file-name-nondirectory info-fn) 0 (- (length ".trashinfo")))) (write-region nil nil info-fn nil 'quiet info-fn))) - ;; Finally, try to move the file to the trashcan. + ;; Finally, try to move the item to the trashcan. If + ;; it's a file, just move it. Things are more + ;; complicated for directories. If the target + ;; directory already exists (due to uniquification) + ;; and the trash directory is in a different + ;; filesystem, rename-file will error out, even when + ;; 'overwrite' is non-nil. Rather than worry about + ;; whether we're crossing filesystems, just check if + ;; we've moving a directory and the target directory + ;; already exists. That handles both the + ;; same-filesystem and cross-filesystem cases. (let ((delete-by-moving-to-trash nil) (new-fn (file-name-concat trash-files-dir files-base))) - (rename-file fn new-fn overwrite))))))))) + (if (or (not is-directory) + (not (file-exists-p new-fn))) + (rename-file fn new-fn overwrite) + (copy-directory fn + (file-name-as-directory new-fn) + t nil t) + (delete-directory fn t)))))))))) + (defsubst file-attribute-type (attributes) -- 2.30.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Fix-trashing-of-symlink-that-points-at-a-directory.patch Content-Description: fix trashing of symlink >From 4aefb5b5964e1aaad0c74238e14ad0a1e3dc4e7a Mon Sep 17 00:00:00 2001 From: Mike Kupfer Date: Sun, 20 Nov 2022 16:44:20 -0800 Subject: [PATCH 2/2] Fix trashing of symlink that points at a directory * lisp/files.el (move-file-to-trash): Redefine is-directory so that it is false for symlinks. --- lisp/files.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index de4f68ebd51..a78d1627689 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -8566,7 +8566,8 @@ move-file-to-trash ;; Make a .trashinfo file. Use O_EXCL, as per trash-spec 1.0. (let* ((files-base (file-name-nondirectory fn)) - (is-directory (file-directory-p fn)) + (is-directory (and (file-directory-p fn) + (not (file-symlink-p fn)))) (overwrite nil) info-fn) ;; We're checking further down whether the info file -- 2.30.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 20 20:45:59 2022 Received: (at 58721) by debbugs.gnu.org; 21 Nov 2022 01:45:59 +0000 Received: from localhost ([127.0.0.1]:44957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvsk-0002iv-M6 for submit@debbugs.gnu.org; Sun, 20 Nov 2022 20:45:59 -0500 Received: from mail-pf1-f171.google.com ([209.85.210.171]:34457) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvsf-0002ie-5r for 58721@debbugs.gnu.org; Sun, 20 Nov 2022 20:45:57 -0500 Received: by mail-pf1-f171.google.com with SMTP id z26so10026621pff.1 for <58721@debbugs.gnu.org>; Sun, 20 Nov 2022 17:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4shNOVNK9lpRBxxiGpP5WGi7PuNLxQY95+f++BqnYag=; b=Xy5O7ZKcghtyrT5NNcpeP/TaAJ4TW8Hde7zYkBscLT0uJy28KoH11L9JWMYnQGdyPb KXo3bMtyhSEko5Pja9boZdEilFi+VtBW4UwGlJPFMaycKl3nSKz4hzAvHqnfMCo6YV8T KZxfvYELSGYx4LLL37GOodHNtLfzP93xj90o0apvWMoUOFrkAjb7ES2X/sdnIWaV90nM TX6GzDmITqVUXkxYzfo2FhXi4pn5ZEyW7SiTSr9pgpjTlcE7mZ82coVxJ0cv9mGj74Qk rsl295102f3xV8UeFagDw8l/OlyT/8V+tjEM/j34liJEWBUv26Rs6nLmEYEdhPCYnz88 I5cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4shNOVNK9lpRBxxiGpP5WGi7PuNLxQY95+f++BqnYag=; b=0Xy8+quf0LzzsaFJi2Ho4g1eNmLHbCt81Qd5k5uHDOOauXPVd+fkgcoLm2lakKc6Y7 rV/FHE4IcJ22H74UBflmz7PXd1v0QRuMez5PxfMot3Z+7x1p3PJMLlAysAqFFD0qTw4a 6epFjVkRUPH1NvcbVppJTn9o0FG8JCOrIsSbUWImcZ6ZQQ+NHMpBHxzw7INWaCdlDrBU itLiGWvhF8TGdigvKWC/L88eoDD1Dmf54gzwGAYUublR7Ae7UYOM/gnsgsFmZxmx/iQJ mQ0WfQmd2nX11fmLkfOQMY2A7obVmxmKCsyJ/rWyy8HHQInBe+0sGYv7RdxfCjERBdbl xsCA== X-Gm-Message-State: ANoB5pndr8jGtWZO9eQgjWZgyawIS8ECt7mboOi7G9HrociZUIMxB7IG kUfM1P6ubCC7xrLUTgYFCAqZKzdeW9joVOJhVMJriUN0 X-Google-Smtp-Source: AA0mqf56uCf+fQM3HaazdH2UoVJAWyWxZNJS2haPDC91R8M7O2Qdp+TEiKvY/4ghB14TLh3lpvMd+QE60lno6lkkRF0= X-Received: by 2002:a63:d403:0:b0:470:1a94:4c0 with SMTP id a3-20020a63d403000000b004701a9404c0mr2767600pgh.555.1668995147190; Sun, 20 Nov 2022 17:45:47 -0800 (PST) MIME-Version: 1.0 References: <66176.1668992898@alto> In-Reply-To: <66176.1668992898@alto> From: Gustavo Barros Date: Sun, 20 Nov 2022 22:45:35 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Mike Kupfer Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hi Mike, On Sun, 20 Nov 2022 at 22:08, Mike Kupfer wrote: > Yes, I tried a few graphical file browsers (Thunar, Caja, and Dolphin), > and they all move the symlink, not the target, to Trash. > > After getting my test setup straightened out, I think I have a fix for > the symlink issue and for the issue that Gustavo originally reported > (cross-filesystem trashing fails when there's already a directory with > the same name in Trash). > > I've committed these fixes separately; see attached. Gustavo, can you > try these out and make sure they handle your use case(s)? Thank you for seeing to this. I've tested the patches, and I'm glad to report `move-file-to-trash` works as expected across file systems. I've also tested symlinks, which work as expected as well. LGTM. (Tests made with 28.2, which is what I have here, and also the version from which the bug was initially filed). Cheers! Gustavo. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 20 20:52:28 2022 Received: (at 58721) by debbugs.gnu.org; 21 Nov 2022 01:52:28 +0000 Received: from localhost ([127.0.0.1]:44962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvz2-0002uw-Ay for submit@debbugs.gnu.org; Sun, 20 Nov 2022 20:52:28 -0500 Received: from shell1.rawbw.com ([198.144.192.42]:25182 ident=root) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owvyz-0002um-MQ for 58721@debbugs.gnu.org; Sun, 20 Nov 2022 20:52:26 -0500 Received: from alto (135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged)) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 2AL1qIxf095028 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 20 Nov 2022 17:52:23 -0800 (PST) (envelope-from mkupfer@alum.berkeley.edu) X-Authentication-Warning: shell1.rawbw.com: Host 135-180-174-133.dsl.dynamic.sonic.net [135.180.174.133] (may be forged) claimed to be alto From: Mike Kupfer To: Gustavo Barros Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice In-Reply-To: Your message of "Sun, 20 Nov 2022 22:45:35 -0300." X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <69977.1668995537.1@alto> Date: Sun, 20 Nov 2022 17:52:17 -0800 Message-ID: <69978.1668995537@alto> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721 Cc: Eli Zaretskii , 58721@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Gustavo Barros wrote: > I've tested the patches, and I'm glad to report `move-file-to-trash` > works as expected across file systems. I've also tested symlinks, > which work as expected as well. > LGTM. Great, thanks for testing. mike From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 24 06:19:31 2022 Received: (at 58721-done) by debbugs.gnu.org; 24 Nov 2022 11:19:31 +0000 Received: from localhost ([127.0.0.1]:57513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyAGR-0007gG-6S for submit@debbugs.gnu.org; Thu, 24 Nov 2022 06:19:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyAGP-0007g4-Ge for 58721-done@debbugs.gnu.org; Thu, 24 Nov 2022 06:19:30 -0500 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 1oyAGJ-0004R0-UA; Thu, 24 Nov 2022 06:19:23 -0500 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=kPMMJaJSgFCdObMd+uBJIb76hkUMpcu9XJ9/g3p+Ezg=; b=qJs3BK0/jN5F O68phth7kswOkx+vPFb71WqCs6okTfdd7OK5haaJwxpq+Yu2pUUZgAgDuLRHBkar63gDdYCsSAaMs OvCOv3h8QrlZ3nS8pWcLOm093Eegizw//rTYdHmIGmuWBhv7of47uBf/dbc58W1U1swnRRQ0NPfno kF5KoLuCFp5PG7ojCcjN/dKVIG/LvIdYxUVCS63fsBaanb4kCgj1yTPINeyeMao1xV7Jgn/5YRaOQ GJcYBYtlaMvkhZIb6q76nPdkEuye6ARQGlCbLWKEh+lDSWjpSWjuFlGH1jX4XSoWF5GRVIHHDlmEt wf0/EQ+dGsSz3sTD0KSC0Q==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyAGJ-0000X3-7x; Thu, 24 Nov 2022 06:19:23 -0500 Date: Thu, 24 Nov 2022 13:19:41 +0200 Message-Id: <83o7swwqeq.fsf@gnu.org> From: Eli Zaretskii To: Mike Kupfer In-Reply-To: <66176.1668992898@alto> (message from Mike Kupfer on Sun, 20 Nov 2022 17:08:18 -0800) Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice References: <66176.1668992898@alto> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 58721-done Cc: 58721-done@debbugs.gnu.org, gusbrs.2016@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Mike Kupfer > cc: 58721@debbugs.gnu.org > Date: Sun, 20 Nov 2022 17:08:18 -0800 > > > I'm not sure either, but my instincts are the same as yours. If that's > > any reference, I just tested here, and that's what "gio trash" does > > (moves the symlink, not the target). > > Yes, I tried a few graphical file browsers (Thunar, Caja, and Dolphin), > and they all move the symlink, not the target, to Trash. > > After getting my test setup straightened out, I think I have a fix for > the symlink issue and for the issue that Gustavo originally reported > (cross-filesystem trashing fails when there's already a directory with > the same name in Trash). > > I've committed these fixes separately; see attached. Gustavo, can you > try these out and make sure they handle your use case(s)? > > > > I'm okay with filing another bug report about rename-file, and > > > discussing this there. But that's a separate issue, and fix of this > > > bug should not depend on that. > > > > Understood. > > Okay. I'm not planning to follow up on this, Gustavo, so if you'd like > to lobby for a change to rename-file, you'll need to open a bug for it > (if you haven't already). No further comments, so I've now installed these changes, and I'm closing the bug. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 24 06:29:14 2022 Received: (at 58721-done) by debbugs.gnu.org; 24 Nov 2022 11:29:14 +0000 Received: from localhost ([127.0.0.1]:57549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyAPp-00086F-Ui for submit@debbugs.gnu.org; Thu, 24 Nov 2022 06:29:14 -0500 Received: from mail-pg1-f172.google.com ([209.85.215.172]:41965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyAPn-000862-3U for 58721-done@debbugs.gnu.org; Thu, 24 Nov 2022 06:29:11 -0500 Received: by mail-pg1-f172.google.com with SMTP id q71so1330554pgq.8 for <58721-done@debbugs.gnu.org>; Thu, 24 Nov 2022 03:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/1La/TAclpBP2frlNHd6KLrUtkvN8A8IWqK2Id/0ryY=; b=lOLYJCTN5A8h1Lq+eM0jJnvVG7xpFxQcfG1oHpFJPQVYMrYtgjG2yG6Fq0aZc9dG+4 17ebnXeZI3oZOWnBTDcT+yI7C3ges2JlMpeRw3o8pgUBPM1dbR6+5sHknsgD38UI82mn fqbUOSFBqWTzonm6x23GcY6Xl8sUD0vtxKFqWZ3wajIP9LZWIbGDCFB94m55l1ILlGT3 o5Kb1c5wUyBqI/RjQ6ir3ARpeHyj5NSuRYtLqoDtsx7iVYZnZw6CnM8nk6taLl4p9p4K /jf5aJ2Y/JAevyH49nIBknT0O4NKOMz0e8q0g02KX8vRzCQINfiqokYQiqsb4vkZYM2W HWkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/1La/TAclpBP2frlNHd6KLrUtkvN8A8IWqK2Id/0ryY=; b=3PPOj7NwRHQ1f2C/z59siG51CiLhvPQoWxbjzIC1HAfNCfJlXcvcfoarLuR8fWwzEa x9JMCyEingGWSefPlU/4OPiMwph5V71jBlD4X8nE9SIsXicQ4rpQ97zGcsmfpvOLQDkH ug4TQa+hnsz61nwX+7ydfjlPlgYokfuOvrMdkzMBc89yyEchGIQrvmENJEHL0lWekCnp EoZXXkLrC+MBsiGxo6pGjlmnG9dmcjK7Y/hAi0eSKqvkLaTopmnzpqeEZbPgOarYGc9d nvf3iSHpkoVNYx8jMi6BYyKMfgObvyiOP+ZdKxTCUlTX3FXRYCCDJY4ebwfGRF9e12+w 3NDQ== X-Gm-Message-State: ANoB5pmv+fvMyxPID/li74Jqp9omgFYdcqmtnsQa00Cb7GjhqDQyGWZo bGF7dAjgn68+80eVdwqmleuKF/ay1XgGq142bf4= X-Google-Smtp-Source: AA0mqf4hUPctPkkah58QF7QFQ4MIlRuaQs/6VL/44vCk8Ds+s3KSWxhgR7OdpJphKYwKpwVw80gwbVdc4pseVp9ooys= X-Received: by 2002:a63:d403:0:b0:470:1a94:4c0 with SMTP id a3-20020a63d403000000b004701a9404c0mr11679441pgh.555.1669289345243; Thu, 24 Nov 2022 03:29:05 -0800 (PST) MIME-Version: 1.0 References: <66176.1668992898@alto> <83o7swwqeq.fsf@gnu.org> In-Reply-To: <83o7swwqeq.fsf@gnu.org> From: Gustavo Barros Date: Thu, 24 Nov 2022 08:28:52 -0300 Message-ID: Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 58721-done Cc: 58721-done@debbugs.gnu.org, Mike Kupfer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Thu, 24 Nov 2022 at 08:19, Eli Zaretskii wrote: > No further comments, so I've now installed these changes, and I'm closing > the bug. Thank you all very much. Gustavo. From unknown Sun Jun 22 01:01:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 22 Dec 2022 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator