Ejemplo n.º 1
0
    async def remount_workspace_new_timestamp(
            self, workspace_id: EntryID, original_timestamp: DateTime,
            target_timestamp: DateTime) -> PurePath:
        """
        Mount the workspace at target_timestamp, and unmount the workspace at the original
        timestamp if it is not None. If both timestamps are equals, do nothing.
        """
        # TODO : use different workspaces for temp mount
        if original_timestamp == target_timestamp:
            try:
                return self._mountpoint_tasks[(workspace_id,
                                               target_timestamp)].value
            except KeyError:
                pass
        new_workspace = await self._load_workspace_timestamped(
            workspace_id, target_timestamp)

        runner_task = await self._mount_workspace_helper(
            new_workspace, target_timestamp)
        if original_timestamp is not None:
            if (workspace_id,
                    original_timestamp) not in self._mountpoint_tasks:
                raise MountpointNotMounted(
                    f"Workspace `{workspace_id}` not mounted.")

            await self._mountpoint_tasks[
                (workspace_id, original_timestamp)].cancel_and_join()
        return runner_task.value
Ejemplo n.º 2
0
    async def unmount_workspace(self,
                                workspace_id: EntryID,
                                timestamp: DateTime = None):
        if (workspace_id, timestamp) not in self._mountpoint_tasks:
            raise MountpointNotMounted(
                f"Workspace `{workspace_id}` not mounted.")

        await self._mountpoint_tasks[
            (workspace_id, timestamp)].cancel_and_join()
Ejemplo n.º 3
0
 def _get_workspace_timestamped(self, workspace_id: EntryID,
                                timestamp: DateTime):
     try:
         return self._timestamped_workspacefs[workspace_id][timestamp]
     except KeyError:
         try:
             self.user_fs.get_workspace(workspace_id)
             raise MountpointNotMounted(
                 f"Workspace `{workspace_id}` not mounted at timestamped `{timestamp}`"
             )
         except FSWorkspaceNotFoundError as exc:
             raise MountpointConfigurationError(
                 f"Workspace `{workspace_id}` doesn't exist") from exc
Ejemplo n.º 4
0
    def get_path_in_mountpoint(self,
                               workspace_id: EntryID,
                               path: FsPath,
                               timestamp: DateTime = None) -> PurePath:
        if timestamp is None:
            self._get_workspace(workspace_id)
        else:
            self._get_workspace_timestamped(workspace_id, timestamp)
        try:
            runner_task = self._mountpoint_tasks[(workspace_id, timestamp)]
            return self._build_mountpoint_path(runner_task.value, path.parts)

        except KeyError:
            raise MountpointNotMounted(
                f"Workspace `{workspace_id}` is not mounted")