async def give_role_to_new_user(self, author, role): # Create new user/device new_device = local_device_factory() await self.backend_data_binder.bind_device(new_device) self.current_roles[new_device.user_id] = None # Assign role author_sock = await self.get_sock(author) if await self._give_role(author_sock, author, new_device, role): return new_device else: return multiple()
async def let_client_monitors_process_changes(self): # Wait for alice client to settle down await trio.sleep(300) # Bob get back alice's changes await self.bob_user_fs.sync() for bob_workspace_entry in self.bob_user_fs.get_user_manifest( ).workspaces: bob_w = self.bob_user_fs.get_workspace(bob_workspace_entry.id) await bob_w.sync() # Alice get back possible changes from bob's sync await trio.sleep(300) # Now alice and bob should have agreed on the data new_synced_files = [] for alice_workspace_entry in self.alice_client.user_fs.get_user_manifest( ).workspaces: alice_w = self.alice_client.user_fs.get_workspace( alice_workspace_entry.id) bob_w = self.bob_user_fs.get_workspace( alice_workspace_entry.id) if alice_workspace_entry.role is None: # No access, workspace can only diverge from bob's continue bob_dump = await bob_w.dump() alice_dump = await alice_w.dump() if self.alice_workspaces_role[ alice_workspace_entry.id] == WorkspaceRole.READER: # Synced with bob, but we can have local changes that cannot be synced recursive_compare_fs_dumps(alice_dump, bob_dump, ignore_need_sync=True) else: # Fully synced with bob recursive_compare_fs_dumps(alice_dump, bob_dump, ignore_need_sync=False) for child_name in bob_dump["children"].keys(): key = (alice_workspace_entry.id, f"/{child_name}") if key not in self.synced_files: new_synced_files.append(key) self.synced_files.update(new_synced_files) return multiple(*(sorted(new_synced_files)))
async def init_good_file_pathes(self): return multiple("/good_file.txt", "/good_folder/good_sub_file.txt")
async def init_good_folder_pathes(self): return multiple("/", "/good_folder/")