unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: fractional file timestamps in tramp-adb
Date: Fri, 15 Feb 2019 14:37:32 -0800	[thread overview]
Message-ID: <4725294c-4855-5b2c-a053-cee9177bc8ef@cs.ucla.edu> (raw)
In-Reply-To: <87zhqxcvyj.fsf@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

On 2/15/19 12:11 AM, Michael Albinus wrote:
> I'm afraid, I'm not an experienced Android developer (tramp-adb.el was
> written by somebody else). Any help appreciated!

Older versions of toybox touch mishandle nanoseconds, and perhaps you've 
run into one of those. How about the attached patch, to try fractional 
timestamps (with "Z" for UTC) if it works, and fall back on the existing 
code otherwise? Plus, we can fall back on touch -t for hosts that don't 
yet support POSIX-2008, though that may be overkill nowadays.


[-- Attachment #2: 0001-Port-tramp-adb-to-various-touch-platforms.patch --]
[-- Type: text/x-patch, Size: 1683 bytes --]

From c4dad9e5d60153870cca647ece7e266b4eb4e19e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 15 Feb 2019 14:36:30 -0800
Subject: [PATCH] Port tramp-adb to various 'touch' platforms

* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Try nanoseconds first, then plain seconds, then touch -t.
---
 lisp/net/tramp-adb.el | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 22f2c5f6bf..4fba4e14f3 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -677,11 +677,22 @@ tramp-adb-handle-set-file-times
 			(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
 			(tramp-compat-time-equal-p time tramp-time-dont-know))
 		    (current-time)
-		  time)))
+		  time))
+	  (quoted-name (tramp-shell-quote-argument localname)))
+      ;; Older versions of toybox 'touch' mishandle nanoseconds and/or
+      ;; trailing "Z", so fall back on plain seconds if nanoseconds+Z
+      ;; fails.  Also, fall back on old POSIX 'touch -t' if 'touch -d'
+      ;; (introduced in POSIX.1-2008) fails.
       (tramp-adb-send-command-and-check
-       v (format "touch -d %s %s"
+       v (format (concat "touch -d %s %s 2>/dev/null || "
+			 "touch -d %s %s 2>/dev/null || "
+			 "touch -t %s %s")
+		 (format-time-string "%Y-%m-%dT%H:%M:%S.%NZ" time t)
+		 quoted-name
 		 (format-time-string "%Y-%m-%dT%H:%M:%S" time t)
-		 (tramp-shell-quote-argument localname))))))
+		 quoted-name
+		 (format-time-string "%Y%m%d%H%M.%S" time t)
+		 quoted-name)))))
 
 (defun tramp-adb-handle-copy-file
   (filename newname &optional ok-if-already-exists keep-date
-- 
2.20.1


  reply	other threads:[~2019-02-15 22:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 18:43 fractional file timestamps in tramp-adb Paul Eggert
2019-02-14 20:23 ` Michael Albinus
2019-02-14 23:41   ` Paul Eggert
2019-02-15  8:11     ` Michael Albinus
2019-02-15 22:37       ` Paul Eggert [this message]
2019-02-16  8:33         ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4725294c-4855-5b2c-a053-cee9177bc8ef@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).