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

Sync file creation timestamps #9191

Open
kennygokh opened this issue Nov 5, 2023 · 25 comments
Open

Sync file creation timestamps #9191

kennygokh opened this issue Nov 5, 2023 · 25 comments
Labels
enhancement New features or improvements of some kind, as opposed to a problem (bug)

Comments

@kennygokh
Copy link

kennygokh commented Nov 5, 2023

Does your log mention database corruption?

No

Include required information

Please be sure to include at least:

  • which version of Syncthing and what operating system you are using
    v1.25.0, macOS (64-bit ARM)

  • browser and version, if applicable
    Chrome, Arc

  • what happened,
    A file was created on 03-Nov-23, see screenshot highlighted in red box. I did a simple update to this file, and you can see modified date shown today date & time (05-Nov-23 11:45). However, when I sync to iPhone, the creation date become today's date.

MacOS Screenshot:
image

iPhone Screenshot:
image

  • what you expected to happen instead, and
    Original file creation date should not be modified. It preserves the creation date of the file which is important for checking subsequently.

  • any steps to reproduce the problem.
    Modify the file in macbook, sync it in mobile.

@kennygokh kennygokh added bug A problem with current functionality, as opposed to missing functionality (enhancement) needs-triage New issues needed to be validated labels Nov 5, 2023
@acolomb
Copy link
Member

acolomb commented Nov 5, 2023

What are you using to sync to the iPhone? Syncthing is not available there.

And are you talking about creation date or modification date? Better to discuss this on the forum, as long as a bug is not clearly identified.

@kennygokh
Copy link
Author

I am using Mobius sync to sync. I am not sure whether it is due to Mobius sync as it might be caused by the sync from macOS syncthing?

@tomasz1986
Copy link
Contributor

The iPhone screenshot only shows one time with no further information. Are you sure that it's supposed to be creation time and not modification time? Usually, when a file explorer only shows one time, it's modification time.

@kennygokh
Copy link
Author

kennygokh commented Nov 5, 2023

Yes. See details screenshot. Both dates were modified as the same date & time.
Screenshot of 20231103 Fri

@acolomb
Copy link
Member

acolomb commented Nov 5, 2023

You will have to take this up with the Möbius Sync people. It's not our product and Syncthing earns nothing from their commercial offering. Thus free support for a commercial software is very limited.

@acolomb acolomb closed this as completed Nov 5, 2023
@kennygokh
Copy link
Author

Ok. I have posted the same at Mobius. By the way, is there a way to use syncthing direct in iOS platform?

@calmh
Copy link
Member

calmh commented Nov 5, 2023

The iOS/Mobius stuff is a red herring; Syncthing doesn't sync creation dates on any platform. Those aren't part of the usual file system APIs and many file systems don't have them to begin with. Nonetheless we could investigate what it would take to do so.

@calmh calmh reopened this Nov 5, 2023
@calmh calmh added enhancement New features or improvements of some kind, as opposed to a problem (bug) and removed bug A problem with current functionality, as opposed to missing functionality (enhancement) needs-triage New issues needed to be validated labels Nov 5, 2023
@calmh calmh changed the title Original File Creation Date Modified After Sync Sync file creation timestamps Nov 5, 2023
@tomasz1986
Copy link
Contributor

Syncthing doesn't sync creation dates on any platform.

I think this issue may not be strictly about syncing creation time. For example, on Windows, even if I update a file on another device and let Syncthing sync the changes to the current device, the file still retains its original creation time after the update. Here, however, it seems that the creation time gets reset on update.

@calmh
Copy link
Member

calmh commented Nov 5, 2023

I don't know what you're seeing, but the behaviour described here makes sense as every synced file is created from scratch. It's just that not that many people look at or care about creation timestamps.

@tomasz1986
Copy link
Contributor

Normally, at least on Windows (and on macOS too, judging by the first screenshot from this very issue), the original creation time gets retained even when files get updated (either locally or through Syncthing).

@calmh
Copy link
Member

calmh commented Nov 6, 2023

Syncthing doesn't "update" files, except in the limited circumstance of just changing permissions or other metadata. If the content has changed it's a new file.

@tomasz1986
Copy link
Contributor

But "updated" is specifically the term Syncthing itself uses! In the GUI, it's either "updated" or "deleted", never "created" (related issue: #7283). Nevertheless, the point is that the original creation date is normally retained even when modifying the file on another device and syncing those modification to the current device, e.g.

image

@calmh
Copy link
Member

calmh commented Nov 6, 2023

I can pretty much guarantee that it isn't.

@tomasz1986
Copy link
Contributor

It is on Windows for sure. Of course, this may be due to how the OS deals with file replacement, not necessarily thanks to Syncthing itself. On the other hand, Android doesn't seem to even support creation time at all. I can't check other OSs right now.

@kennygokh
Copy link
Author

When the file first created, it should retain the state of the file regardless of which OS platform. That is why there is an attribute like Creation Date. When sync happen, if the file content differs, it should retain the original state of file creation date & time, however the content differ, sync should update only modify date & time. It's the same behavior in other platform like iCloud, OneDrive etc.

@tomasz1986
Copy link
Contributor

Related: https://forum.syncthing.net/t/feature-request-sync-creation-times-dates/9184

@kennygokh Can you test what happens the other way around? Basically, just modify the file on the iOS side and see what happens with the creation and modification dates on the Mac.

@er-pa
Copy link
Member

er-pa commented Nov 6, 2023

It is on Windows for sure. Of course, this may be due to how the OS deals with file replacement, not necessarily thanks to Syncthing itself. On the other hand, Android doesn't seem to even support creation time at all. I can't check other OSs right now.

On Windows it just retains the creation date of when the file is being created on that Windows machine, it still doesn't retain any 'original' creation date from the sending side. But even so, Windows seems to be a special case as MacOS and Linux never retain that creation date.

And indeed, Android with its emulated FS is another special case. There does seem to be some support for it since API 26, but it doesn't seem to result in much.

@kennygokh
Copy link
Author

Related: https://forum.syncthing.net/t/feature-request-sync-creation-times-dates/9184

@kennygokh Can you test what happens the other way around? Basically, just modify the file on the iOS side and see what happens with the creation and modification dates on the Mac.

I am not able to try as I get insufficient disk space error. The same error (see screenshot) encountered even though I created a test vault with a small file. image

@tezlm
Copy link

tezlm commented Nov 26, 2023

This is also an issue on linux. Some filesystems like btrfs have birthtime, but syncthing doesn't seem to set it on synced files.

@calmh
Copy link
Member

calmh commented Nov 26, 2023

I don't think there's even an API to set that timestamp. It cannot be synced.

@rasa
Copy link
Member

rasa commented Nov 26, 2023

OpenWRT 23.05 doesn't appear to support birthdates in a default install:

find / -print0 2>/dev/null | xargs -0 -n 1 stat 2>/dev/null | grep "^Birth:" | grep -v "^Birth: -" | wc
        0         0         0

@fx-k
Copy link

fx-k commented Jan 1, 2024

Just wanna say as a Windows user, I really need this feature. Windows Explorer enables sorting by folder/file creation time by default, which is so necessary for me to find my documents. So, strongly hoping to this :-)

A temporary solution may be (before this function is implemented), we can use some kind of programming to synchronize the file creation time during the initial synchronization, and then keep syncthing turned on, and it will continue to synchronize new additions files (perhaps with a slight time offset).

@milroneth
Copy link

milroneth commented Jan 12, 2024

To clear some things up for everyone:

The Creation timestamp does not "belong" to the file. It belongs to the filesystem (partition, disk) that contains it. Some filesystems don't even store this at all, so it's not a universal idea. While the modification time should follow the file around, the creation time does not (and it shouldn't, this isn't what it's meant for).

Even in Windows that we are used to rely on Creation Time, it's not guaranteed to be preserved. For example, if you copy a file you made yesterday, you will notice that the copy has a creation time of NOW even if it says modified yesterday. If you then delete the original and keep the copy, it would be almost equivalent as if you moved it, but the original creation time is lost, it is a newly created file after all.

If you move the file around in the same partition (say you make a subfolder and put it in), it's preserved. If you move the file to a USB disk, you will again see that the creation time is lost and changed to now. That is correct, the file was JUST NOW created on the USB stick, even if it was modified on some other disk earlier.

To re-iterate, the creation timestamp is the storage medium telling you when it saw that file for the first time, not when you first made it. Those 2 just happen to initially coincide when you make a new file from scratch.

So, when you copy or backup files, the creation time is always "new" for the copy, if it even exists at all, as some don't store that value. Modification times should always be preserved and when they are not that is wrong and shouldn't happen, but not so for creation times.

Lastly, as some of you noticed and in some cases, updating a file can also update its creation time to now, along with its modification time. That happens because certain apps don't edit the original file when they have to update it but instead save a whole new file to replace the old one. This is either done unnecessarily, out of weirdness, or for safety reasons. In the later case the new file is initially saved with a new filename, then the old one deleted and the new one renamed to take its place. This saves your file in case the operation is interrupted as the original is still untouched until the new one is safely stored. This is very common behaviour for backup/sync software so that you don't end up with only half-transfered files and no originals and lose your data.

In conclusion, Creation time is useful, but only to an extent, don't count on it. If you need to know when a file was created, put that in the filename.

In the case of the original poster, I'm not sure the iPhone even stores creation times at all. On the contrary, its storage system for user files is so unorthodox, it may often lose the modification time as well when it receives files and apply the current time instead, with a lot fewer options to avoid that than we have on other systems. As in, every file you put on an iPhone is "modified" when you put it on the iPhone, even if YOU didn't changed it, the iPhone did. It wasn't there before, now it is, that's a modification 🤦‍♀️ This of course varies from app to app, but still it is seriously one of the reasons I have never owned an iOS device. I too care about timestamps and iOS likes to mess with them constantly to the point that it's unusable for me.

@lynrayy
Copy link

lynrayy commented May 24, 2024

Is it fixed?
I want to sync photos FROM my phone TO windows with original file creation dates. Wtf? How to change it?

@milroneth
Copy link

Is it fixed? I want to sync photos FROM my phone TO windows with original file creation dates. Wtf? How to change it?

It can't be fixed because it's not broken. Please read my extensive answer that you skipped, it's right above your comment, it will explain everything. Short answer: nothing preserves that, not even Windows itself when you transfer photos from an SD card with the file manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or improvements of some kind, as opposed to a problem (bug)
Projects
None yet
Development

No branches or pull requests

10 participants