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