From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#58842: 29.0.50/tramp; copy-file KEEP-TIME gives the target earlier time Date: Sun, 30 Oct 2022 16:42:21 +0100 Message-ID: <87v8o1jp2a.fsf@gmx.de> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12538"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 58842@debbugs.gnu.org To: Sam Steingold Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 30 16:43:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opAT1-00034Q-TW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Oct 2022 16:43:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opASm-0001ew-4a; Sun, 30 Oct 2022 11:43:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opASk-0001en-Ox for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2022 11:43:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opASk-0007xF-7f for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2022 11:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1opASj-0006J6-Hx for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2022 11:43:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Oct 2022 15:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58842 X-GNU-PR-Package: emacs Original-Received: via spool by 58842-submit@debbugs.gnu.org id=B58842.166714455124205 (code B ref 58842); Sun, 30 Oct 2022 15:43:01 +0000 Original-Received: (at 58842) by debbugs.gnu.org; 30 Oct 2022 15:42:31 +0000 Original-Received: from localhost ([127.0.0.1]:38849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opASE-0006IL-Ng for submit@debbugs.gnu.org; Sun, 30 Oct 2022 11:42:31 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:33773) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opASD-0006I7-KT for 58842@debbugs.gnu.org; Sun, 30 Oct 2022 11:42:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1667144543; bh=cWSPlHTsRk0m9qsWdKylrQ9LAE6l83W6wusl7nKPYsQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=K2qP77PK2HVLW5Ug2NrTfPLdBwVBC75Xixobmczw1UVvJxPahMwg4vjq6VlLoiRS0 S64QqhwwkyeUzhayosKvrJ2K0CRuVMcWSB4oBt/6ir2D/u6zsOvG9x7MUzQeIU+TCD 6ybI2Er+kLEcYy34WB8NeIffQDlF3tYML4sNcsR0Vg1ocyBjPMLqYArvv8FI1olKLl PEwMYNwKyluahggd1R0th4FeiePXA/BmVNPOZ9hH0UQOEt9fpla/m+tEZ447lQUXZj bIg1NQ/Ia+1s21s6v+4GrDXNKeQ4oYvIB+Jf4gAQoeDf/gmp8dWqJ4/SUzFESmmSM6 Qv7Fhs11cz+MA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([217.70.140.62]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTiPl-1odROk0fNt-00TzmV; Sun, 30 Oct 2022 16:42:23 +0100 In-Reply-To: (Sam Steingold's message of "Fri, 28 Oct 2022 12:39:31 -0400") X-Provags-ID: V03:K1:kgtBkAJKMtUFLz/4E80pVV1dd0WL8j2IK+36ZtQmtRLlyUF/bIB VfW3XmmSvD948zNuU1++oWdKU40EhcxXCRAfWjygCkZCmB84uz2jYPuKBCLwJ29n8AKP5Fe 1TG+0Vz2iy/YlNtIX4jdwZCjs9jvNK2OPqY2L/ia5GvHz/36ybDn8WBxL7vg1fjAMqAnzMY KPKrPb2LrKCQizyHGWJkQ== UI-OutboundReport: notjunk:1;M01:P0:JNm3/KsUEp8=;GB4R756mt69EVDTcMv87PjGG3c7 6Db8RB1sVc3/rrHuNRKqe7Yoe6LMdhrnRE9r0/YhlVClnJU2X8qY0WFfQix648zH5HWUYXgTU eergVVxydIQhA1Lv9WUXjR7tSfnDH81XqbMwA7n2seb8wJbCbleaMh0ycGiOyiff8o6xsPnvZ eTi3bpDqVNkN57yBl8+k0k+1D9kAOluwO6U7/Pgo1UH88riZ8JRwp4OgIF/xaAd9wT5OB27d7 g9C8jIM0MdjqSUzZvhRuvdMJE3YTEqpD+aTwoWkFHEUApLe7ZYG4mBacB4+5JWHr97NT75CkY PX2/3RosXkalzrTllTRrOqqfWaR+Rvn2rEpHmDoI4ilP31b4ozF6Pq6Hm8J4uNYPuKbRnaZO3 IN90ULaabMQDfRc1SREm35a52Lc8GKvtih7m4OSL61kexiymB3JOIz+9nunCDjKun1iABNEHh SfWQ4o/I7wehrl6EQbdTHmwSFzGWdZFXgXZQx0tmy2uSu/GFz8DGU4vkdvxXKtKVOQP4Euott JjRBPBod8oEisXHAl5n/q+A3MpVDDIelS6tpFDWaCu7p8XCQofFoUfN7G4CrhMFcceLWmiw8q Nr9qvdbfpuUn8jzd6nNAhOwOCoQH0enaT7poVWm8LWh7hvZ/6R9LbSkSXFzWrnYrxIWPrtuSK MAo7tSmpPW5c3ih3O8OoB+Ki4uS29JPUySoOnproLh5zQrEtoa0CeYTaGE/kSHnUekU2mJWTU FPUGxKBS4iZ6TC1Aj+uhSDgSggliAKt7/tPFM1YWMOTojnF3MXmruMpbhIneK/z8JdjbTbKT X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246633 Archived-At: --=-=-= Content-Type: text/plain Sam Steingold writes: Hi Sam, > One property of `copy-file' that I came to expect is: > > (copy-file src dst ...) is successful > ==> > (file-newer-than-file-p src dst) is false > > This ensures that the same file is not copied over and over. > > Alas, this does not hold in the following corner case: > > 1. src is local on mac > 2. dst is remote on linux > 3. KEEP-TIME is passed to `copy-file' > > In this case, after `(copy-file src dst t t)`, > > (file-attribute-modification-time (file-attributes dst)) > => (25435 65247 0 0) > (file-attribute-modification-time (file-attributes src)) > => (25435 65247 279367 729000) > > I understand this is bad behavior is covered by the `copy-file' doc > > Fourth arg KEEP-TIME non-nil means give the output file the same > last-modified time as the old one. (This works on only some systems.) > > but it would seem to be relatively easy to fix by rounding _up_ the time > before calling the tramp handler for `set-file-times'. Well, another fix would be to teach file-newer-than-file-p to use only seconds w/o fractions. Does the appended patch works for you? > Thank you. Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment diff --git a/lisp/tramp.el b/lisp/tramp.el index 933bac7e..59306635 100644 --- a/lisp/tramp.el +++ b/lisp/tramp.el @@ -4029,6 +4029,17 @@ Let-bind it when necessary.") (cond ((not (file-exists-p file1)) nil) ((not (file-exists-p file2)) t) + ;; Tramp reads and writes timestamps on secon level. So we round + ;; the timestamps to seconds w/o fractions. + ;; `time-convert' has been introduced with Emacs 27.1. + ((fboundp 'time-convert) + (time-less-p + (tramp-compat-funcall + 'time-convert + (file-attribute-modification-time (file-attributes file2)) 'integer) + (tramp-compat-funcall + 'time-convert + (file-attribute-modification-time (file-attributes file1)) 'integer))) (t (time-less-p (file-attribute-modification-time (file-attributes file2)) (file-attribute-modification-time (file-attributes file1)))))) --=-=-=--