spion / adbfs-rootless

Mount Android phones on Linux with adb. No root required.
Other
890 stars 73 forks source link

Timestamps are lost when copying to device #59

Open IzzySoft opened 1 year ago

IzzySoft commented 1 year ago

When copying files over adbfs to the device, timestamps are lost – the file shows up as were it just created anew on the device. This happens even when explicitly specifying to keep timestamps (e.g. rsync -rltDcu), without any error message being shown (and yes, I have to use -c there as otherwise timestamps would be messed up on the PC as well when synced back, despite of the -u). Same happens with cp or any other means of copying.

Is there any way to preserve times?

IzzySoft commented 1 year ago

Are you that fdroid repo guy ?

Yepp, one of those :wink:

I think timestamp lost because the source & destination file systems are different

definitely not.

One workaround, is to zip them, transfer to your device & extract.

Doesn't work with rsync, sorry. My work-around is a little different. Still, it's a work-around and not a real solution. If the sync could adhere the timestamp directly (i.e. the FUSE system provided by adbfs supporting it), that would be much better – if it's possible. Not ranting, just asking and suggesting :wink:

IzzySoft commented 1 year ago

I still wonder why this happens. If I perform an adb push example.txt /sdcard/, timestamps are preserved. Isn't that what adbfs executes as well, with the very same version of adb my manual push performs?

void adb_push_pull_cmd(string& cmd, const bool push,
               const string& local_path, const string& remote_path)
{
    cmd.assign("adb ");
    cmd.append((push ? "push '" : "pull '"));
    cmd.append((push ? local_path : remote_path));
    cmd.append("' '");
    cmd.append((push ? remote_path : local_path));
    cmd.append("'");
}

queue<string> adb_push(const string& local_source,
               const string& remote_destination)
{
    string cmd;
    adb_push_pull_cmd(cmd, true, local_source, remote_destination);
    queue<string> res = exec_command(cmd);
    invalidateCache(remote_destination);
    return res;
}  

If I'm not mistaken, adb_push_pull_cmd would construct a string adb push '<local_path>' '<remote_path>', which then in adb_push would be sent to exec_command where it is processed using popen(command.c_str(), "r" ) and then the output parsed. So why does that give a different result? Isn't it the very same command?