How does the iCloud drive work from a technical standpoint when sharing files between Windows and iOS?

571 Views Asked by At

I would like to understand how the iCloud drive works behind the scenes, specifically when sharing files between PC and iOS apps via iCloud drive. With the Microsoft iCloud program installed on Windows 10 it shows the iCloud drive in the file explorer:

  1. I assume it's just a shortcut to the C:\users\username\iCloudDrive directory?
  2. when you copy a file to the iCloudDrive it's copied to that local iCloudDrive directory?
  3. the "iCloud Drive" process running in the background checks for any changes to files and folders in that local directory? How? does it use the "last modified" datetime stamp or does the file system notify the process of a change?
  4. the process then copies the entire file to the iCloud service? It updates the status to "green checkmark"
  5. when a file changes in the iCloud what mechanism is used to update the local file?
  6. does it prevent one file overwriting the other if both change at the same time? Does it "lock" a file while it's being updated?
  7. Does the same mechanism apply to iOS app accessing files on the iCloudDrive (save to local file system first, background process handles with the syncing, locking, etc)?
  8. in the logs I see references to CheckIfToHydrateOrDehydrateFile. What does that mean in this context?
2

There are 2 best solutions below

0
FOREVEREALIZE On

I do not work for Apple nor know for a fact how it works but here are my logical assumptions (with a lot of general technical knowledge) for each question.

  1. It is
  2. When you upload something to iCloud from your iPhone (or other Apple device) your PC (Windows PC) has a process running in the background that will ask the iCloud servers if there is anything new, if there is, it will download it. Same goes the other way around.
  3. The background process on your PC (Windows PC) knows if there has been any change by hashing each file with a hashing algorithm such as SHA-256 and checking against a database of the last hash it got from a file, if the hash is not the same, we upload the file to iCloud.
  4. Yes, the iCloud background process on your PC (Windows PC) will upload any files that have been detected to change (See number 3) to the iCloud servers and, when it is done, it puts that little green checkmark to the side of the file.
  5. See number 2
  6. If for that you mean that if the same file (let's say "document.txt") changes on the PC (Windows PC) and iPhone (or other Apple device), what will iCloud do, then the answer is that it is up to "chance". Let me explain, it is up to what device is phisically closer to the router, if it is connected by cable or not, when (millisecond precision intended) you turned on the device, how much did the device take to open the iCloud service, device speed, internet speed, internal Apple server speed, etc. Basically, a whole bunch of factors that affect what request hit the Apple servers first. And no, the requests hitting the servers at the same time cannot happen, since there is an action queue in place that grabs one request until the other and puts it in a queue until it is it's turn and the queue cannot have two requests at the same turn.
  7. Yes
  8. That I do not know because it is the message that Apple put in place for that action and would have to be answered by someone who works at Apple.

I hope this helps to answer your questions.

0
RayWNZ On

That’s a very interesting insight and explains a lot. I have an Access database app that I run on my Mac using Parallels (Windows 11). The database is in iCloud with a copy synced to my Mac. Recently I shared (collaborate) the database with my colleague running iCloud for Windows.

The trick is for my colleague to check in iCloud for Windows that the database is synced (Green symbol) when he wants to use it.

I use Finder and iCloud folder to check the database synchronisation is up to date by viewing the iCloud sync status on the bottom of the Finder window. Any backlog queue could potentially and effectively cause iCloud version control problems.

If this logic is flawed I’d like to know, but it does explain why some people give up on iCloud folder and file sharing. I haven’t seen any mention from Apple of iCloud having folder, file or record locking that a DBMS would have.