Skip to content

Commit

Permalink
Fix gui reencryption need offline handling (#1016)
Browse files Browse the repository at this point in the history
* Correct RemoteDevicesManagerInvalidTrustchainError exception in RemoteDevicesManager

* Fix missing republish of RemoteDevicesManager exceptions in WorkspaceFS.get_reencryption_need

* Fix offline GUI handling in WorkspacesWidget
  • Loading branch information
touilleMan authored Mar 6, 2020
1 parent e9b87dc commit e5ac903
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions newsfragments/1016.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error handling during workspace reencryption detection when offline.
22 changes: 17 additions & 5 deletions parsec/core/fs/workspacefs/workspacefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
LocalFileManifest,
DEFAULT_BLOCK_SIZE,
)
from parsec.core.fs import workspacefs
from parsec.core.remote_devices_manager import (
RemoteDevicesManagerBackendOfflineError,
RemoteDevicesManagerError,
)
from parsec.core.fs.exceptions import FSError, FSBackendOfflineError
from parsec.core.fs.remote_loader import RemoteLoader
from parsec.core.fs import workspacefs # Needed to break cyclic import with WorkspaceFSTimestamped
from parsec.core.fs.workspacefs.sync_transactions import SyncTransactions
from parsec.core.fs.workspacefs.versioning_helpers import VersionLister
from parsec.core.fs.utils import is_file_manifest, is_folderish_manifest
Expand Down Expand Up @@ -166,10 +171,17 @@ async def get_reencryption_need(self) -> ReencryptionNeed:
has_role.add(certif.user_id)

user_revoked = []
for user_id in has_role:
_, revoked_user = await self.remote_device_manager.get_user(user_id, no_cache=True)
if revoked_user and revoked_user.timestamp > wentry.encrypted_on:
user_revoked.append(user_id)
try:
for user_id in has_role:
_, revoked_user = await self.remote_device_manager.get_user(user_id, no_cache=True)
if revoked_user and revoked_user.timestamp > wentry.encrypted_on:
user_revoked.append(user_id)

except RemoteDevicesManagerBackendOfflineError as exc:
raise FSBackendOfflineError(str(exc)) from exc

except RemoteDevicesManagerError as exc:
raise FSError(f"Cannot retrieve workspace participant {user_id}: {exc}") from exc

return ReencryptionNeed(user_revoked=tuple(user_revoked), role_revoked=tuple(role_revoked))

Expand Down
5 changes: 4 additions & 1 deletion parsec/core/gui/workspaces_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@


async def _get_reencryption_needs(workspace_fs):
reenc_needs = await workspace_fs.get_reencryption_need()
try:
reenc_needs = await workspace_fs.get_reencryption_need()
except FSBackendOfflineError as exc:
raise JobResultError("offline") from exc
return workspace_fs.workspace_id, reenc_needs


Expand Down
4 changes: 2 additions & 2 deletions parsec/core/remote_devices_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def get_user(
None if no_cache else self._trustchain_ctx.get_revoked_user(user_id)
)
except TrustchainError as exc:
raise RemoteDevicesManagerError(exc) from exc
raise RemoteDevicesManagerInvalidTrustchainError(exc) from exc
if not verified_user:
verified_user, verified_revoked_user, _ = await self.get_user_and_devices(
user_id, no_cache=True
Expand All @@ -102,7 +102,7 @@ async def get_device(
try:
verified_device = None if no_cache else self._trustchain_ctx.get_device(device_id)
except TrustchainError as exc:
raise RemoteDevicesManagerError(exc) from exc
raise RemoteDevicesManagerInvalidTrustchainError(exc) from exc
if not verified_device:
_, _, verified_devices = await self.get_user_and_devices(
device_id.user_id, no_cache=True
Expand Down

0 comments on commit e5ac903

Please sign in to comment.