meganz / MEGAsync

Easy automated syncing between your computers and your MEGA Cloud Drive
Other
1.58k stars 278 forks source link

OS Time sync #822

Closed LSmyrnaios closed 11 months ago

LSmyrnaios commented 11 months ago

Is MegaSync automatically forcing a time sync in the OS, before it starts scanning for changes? It may be the case that the local time is behind/ahead of the global time.

LSmyrnaios commented 11 months ago

After thinking this again, I would like to add some notes:

1) If MegaSync does force the OS to sync the time, it may not change anything in the sync operation, since the "last modified" times of the files will not be automatically corrected. 2) there is no way to know for certain if the "last modified time" of a file, was assigned at a time of misalignment with the global time. The misalignment might have happened afterwards. This also means that even if one can calculate the misalignment from global time, a time-offset cannot be applied to all "last modified" dates of the files.

I am interested in how MegaSync handles this time-misalignment issue.

mattw-mega commented 11 months ago

Hi @LSmyrnaios , MEGAsync does not ask or force any OS to update its time. Each OS should have a way to coordinate that anyway, to synchronize its clock with internet servers. I'm sure you can enable that for whichever one you are using.

Current production megasync (4.x) can be quite sensitive to the modification time, because it always picks the one with the greater mtime. If your local time is older, and you just saved a new version of a file, the sync could download the cloud version and overwrite your local changes, if it had a file with a greater mtime. However that is getting fixed in version 5.x which has far better logic. In that one, whichever side changed is the side to get uploaded/downloaded to the other side. So, even if your clock was so far behind that your just-written file copy was "older" (by mtime) than the corresponding cloud file, we would still upload it. You can try out the new version in #770 though it is still Alpha software - it may have bugs, please make sure all your files are backed up elsewhere just in case.

Oh, one other thing- if you are seeing this a lot, then I wonder if you are using FAT, FAT32, exFAT etc drives. All the FAT formats have an extremely basic version of how time is recorded. It just stores the current user time, and does not note what time zone that was, or whether daylight savings was in effect etc. So, if you change time zones or go in or out of daylight savings, then all the mtimes in MEGA etc will adjust to reflect the new settings - ie, same actual real time but as it would be displayed by a clock in your new zone. However FAT will continue to show the same time. So, that can cause mtime comparisons to change and cause uploads/downloads that way.

thanks

LSmyrnaios commented 11 months ago

Thank you @mattw-mega for the detailed explanation.

I hope the production release of v.5 comes soon and smoothly.

I have NTFS file system on Windows 10. I have not seen any issues related to time-sync, but I have caught Windows to have misaligned-time quite a few times, so I was wondering if/how it was affecting files-sync.