Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamps are lost when copying to device #59

Open
IzzySoft opened this issue Dec 13, 2022 · 3 comments
Open

Timestamps are lost when copying to device #59

IzzySoft opened this issue Dec 13, 2022 · 3 comments

Comments

@IzzySoft
Copy link

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
Copy link
Author

Are you that fdroid repo guy ?

Yepp, one of those 😉

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 😉

@IzzySoft
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@IzzySoft and others