From ebffba9589903aa94ec960c8075f8c6adb0f9f13 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Sun, 4 Feb 2018 08:55:19 -0800 Subject: [PATCH] Add bi-directional syncing note from Quenty --- DESIGN.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/DESIGN.md b/DESIGN.md index dba5d405..bd2094e7 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -36,4 +36,14 @@ The plan is to have several built-in plugins that can be rearranged/configured i * User passes a binary name (like `moonc`) that modifies file contents ## Roblox Studio Plugin -With the protocol version 1 change, the Roblox Studio plugin got a lot simpler. Notably, the plugin doesn't need to be aware of anything about the filesystem's semantics, which is super handy. \ No newline at end of file +With the protocol version 1 change, the Roblox Studio plugin got a lot simpler. Notably, the plugin doesn't need to be aware of anything about the filesystem's semantics, which is super handy. + +## Bi-directional syncing +Quenty laid out a good way to handle bi-directional syncing. + +When receiving a change from the plugin: +1. Hash the new contents of the file, store it in a map from routes to hashes +2. Write the new file contents to the filesystem +3. Later down the line, receive a change event from the filesystem watcher +4. When receiving a change, if the item is in the hash map, read it and hash those contents +5. If the hash matches the last noted hash, discard the change, else continue as normal \ No newline at end of file