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

--local-times mtime/ctime/atime #7484

Closed
cberni opened this issue Dec 4, 2023 · 5 comments
Closed

--local-times mtime/ctime/atime #7484

cberni opened this issue Dec 4, 2023 · 5 comments

Comments

@cberni
Copy link

cberni commented Dec 4, 2023

The associated forum post URL from https://forum.rclone.org

https://forum.rclone.org/t/min-age-and-max-age-support-for-atime-and-ctime/2122

What problem are you are trying to solve?

We would need use "ctime" on rclone move with filters (--max-age --min-age).
It appears that rclone only uses "mtime".
This is only needed when moving from local to remote (/local to remote:bucket).

Access Time (atime):
    Represents the last time the file was accessed or read.
    Updated when the file is opened or read.

Modify Time (mtime):
    Represents the last time the file's content was modified or changed.
    Updated when the file's content is altered.

Change Time (ctime):
    Represents the last time the file's metadata was changed.
    Updated when the file's metadata is modified (e.g., permissions are changed) or when the file is created or deleted.

How do you think rclone should be changed to solve that?

create a flag --local-times mtime/ctime/atime as @ncw already noted.

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
@ncw
Copy link
Member

ncw commented Dec 7, 2023

Which OS are you using? Windows/Linux or macOS?

Can you try this on your target platform?

rclone -M lsjson --stat /path/to/file

This will show something like

{
	"Path": "z.txt",
	"Name": "z.txt",
	"Size": 270,
	"MimeType": "text/plain; charset=utf-8",
	"ModTime": "2023-05-11T17:54:11.523399602+01:00",
	"IsDir": false,
	"Metadata": {
		"atime": "2023-05-11T17:54:11.523399602+01:00",
		"btime": "2023-05-11T17:54:11.523399602+01:00",
		"gid": "1000",
		"mode": "100664",
		"mtime": "2023-05-11T17:54:11.523399602+01:00",
		"uid": "1000"
	}
}

We don't currently read ctime though as I didn't think it was generally useful!

Here is what the statx man page says

       stx_atime
              The file's last access timestamp.

       stx_btime
              The file's creation timestamp.

       stx_ctime
              The file's last status change timestamp.

       stx_mtime
              The file's last modification timestamp.

Do you definitely want ctime?

@cberni
Copy link
Author

cberni commented Dec 7, 2023

rclone v1.65.0
- os/version: ubuntu 20.04 (64 bit)
- os/kernel: 5.4.0-167-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.4
- go/linking: static
- go/tags: none
{
        "Path": "D8AE7973",
        "Name": "D8AE7973",
        "Size": 153880,
        "MimeType": "application/octet-stream",
        "ModTime": "2021-05-13T17:02:28.642208939-03:00",
        "IsDir": false,
        "Metadata": {
                "atime": "2023-12-06T15:30:48.776379588-03:00",
                "btime": "2023-12-06T15:30:48.772379758-03:00",
                "gid": "0",
                "mode": "100644",
                "mtime": "2021-05-13T17:02:28.642208939-03:00",
                "uid": "0"
        }
}

yes. We need it because we are working with union /local:writeback
in this case the most important is the time the file was "copied back" e not the time it was modified.

@ncw
Copy link
Member

ncw commented Dec 8, 2023

Give this a go

v1.66.0-beta.7573.b36b0f3d1.fix-7484-local-time-type on branch fix-7484-local-time-type (uploaded in 15-30 mins)

--local-time-type

Set what kind of time is returned.

Normally rclone does all operations on the mtime or Modification time.

If you set this flag then rclone will return the Modified time as whatever
you set here. So if you use "rclone lsl --local-time-type ctime" then
you will see ctimes in the listing.

If the OS doesn't support returning the time_type specified then rclone
will silently replace it with the modification time which all OSes support.

  • mtime is supported by all OSes
  • atime is supported on all OSes except: plan9, js
  • btime is only supported on: Windows, macOS, freebsd, netbsd
  • ctime is supported on all Oses except: Windows, plan9, js

Note that setting the time will still set the modified time so this is
only useful for reading.

Properties:

  • Config: time_type
  • Env Var: RCLONE_LOCAL_TIME_TYPE
  • Type: mtime|atime|btime|ctime
  • Default: mtime
  • Examples:
    • "mtime"
      • The last modification time.
    • "atime"
      • The last access time.
    • "btime"
      • The creation time.
    • "ctime"
      • The last status change time.

@cberni
Copy link
Author

cberni commented Dec 8, 2023

awesome!

I tested all the types here on linux and it is fully working. I our case we'll use "atime". Great!

@ncw
Copy link
Member

ncw commented Mar 26, 2024

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.67

It is too big a patch for v1.66.1

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