Feature Request - Sync Creation Times/Dates

Hi I cannot find if this is the right place for this, but I would like Syncthing to synchronize the File and Directory Creation Time. Is there a chance to have this one day? (and is there a Feature Request somewhere with a voting system?) Many Thanks Eric

2 Likes

There is typically no separate creation date stored that Iā€™m aware of. Modification times of directories we do not sync, because itā€™s annoying. Essentially, syncing a file in a directory will update the modification of the directory, so weā€™d need to recurse upwards resetting modification times after each change. We did this at one point, but it was a fair amount of work and not 100% reliable.

Thanks for your reply Jakob.

I have found on stackexchange.com: ā€œLinux doesnā€™t keep track of the creation time since it is not required by POSIX. However, Mac OS X does with the HFS filesystem ā€” look under ā€œbirth timeā€ in statā€

As you can guessā€¦ I am working on mac. Once newly synchronised, all the files are dated ā€œtodayā€. I understand for directories, but for files, itā€™s a pity that the creation dates are not set same as the original ones. Would it be possible that this is implemented for Mac?

Thanks again Eric

1 Like

Cool, I learned something new about Mac :slight_smile:

No, this is vanishingly unlikely that we would implement, given that we mostly stick the common denominator of all supported OS:es.

I donā€™t see why we could not support it on platforms that support it, but I donā€™t think Go exposes btime, nor do I see anyone entertained enough to make this happen.

Recently started using Syncthing (replacing Dropbox), and all directories on the ā€˜secondā€™ machine have as date the moment Syncthing first synced. Iā€™d like the dates on the second machine to be the same as on the first machine.

I often use ls -ltr, e.g. to get to the projects Iā€™ve last worked on. Perhaps not the best workflow, but Iā€™m used to it. (Then again, why do directories have dates if weā€™re not supposed to use them?) Perhaps I can approximate the original date by writing a script that gives each directory the date of the latest modified file in the directory.

It seems not necessary to do anything recursive to achieve the desired behavior. Just copy over the date when syncing directories for the first time, and then keeping them in sync when they change. About the date to use, Iā€™d say the date that window managers of the OS show by default. What users see is what matters most, irrespective of whether this is atime, btime, ctime or whatever.

Running this bash command in my Sync directory was good enough for me:

find . -type d ! -empty | tac | while read -r dir
do
touch -t $(ls -pAl --time-style="+%Y%m%d%H%M.%S" "$dir" | tail -n +2  | awk '{print $6}' | sort -n | tail -n 1) "$dir"
done

It traverses all directories (find . -type d ! -empty), deepest directories first (tac). It works with directories with spaces (while read -r). Then it lists the contents in those directories (ls -pAl) with a timestamp that touch accepts (--time-style="+%Y%m%d%H%M.%S"), removes the ā€˜totalā€™ line (tail -n +2), selects only the timestamps (awk '{print $6}'), sorts them numerically (sort -n), picks the latest one (tail -n 1) and sets the directory time to that (touch -t). It doesnā€™t as desired when there are empty directories.

The directory times on my second machine are not the same as on my first machine, but good enough.

2 Likes

From the StackExchange question you linked

Modern Linux filesystems, such as ext4, Btrfs, XFS (v5 and later) and JFS, do store the file creation time (aka birth time), but use different names for the field in question (crtime in ext4/XFS, otime in Btrfs and JFS).

Iā€™m adding my vote to support syncing btime if supported by fs. Resetting btime loses a piece of metadata that could be useful, especially for documents and notes that were not date-stamped.

1 Like

Very need this feature, a Windows user.

Thank you.

Please, can you add this feature, another Windows User here. It would be great if folderā€™s date creation, date modified could be transfered aswellā€¦ The best feature would also be, syncthing to use the latest file as folderā€™s modified dateā€¦