Skip to content

Commit

Permalink
Merge pull request #1637 from Scille/remove-deprecated-addr-rvk
Browse files Browse the repository at this point in the history
Cleanup deprecations in backend addrs
  • Loading branch information
touilleMan authored Jun 18, 2021
2 parents 702fc5f + 65f43a0 commit 2d2dfe2
Show file tree
Hide file tree
Showing 22 changed files with 714 additions and 822 deletions.
20 changes: 20 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ disallow_subclassing_any=True
[mypy-parsec.core.fs.workspacefs.versioning_helpers]
disallow_untyped_defs=False

[mypy-parsec.core.gui.*]
# Qt doesn't provide typing
disallow_any_unimported = False

[mypy-parsec.core.gui.central_widget]
ignore_errors = False
disallow_untyped_defs=True
disallow_any_decorated=True
disallow_any_explicit=True
disallow_any_generics=True
disallow_subclassing_any=True

[mypy-parsec.core.gui.main_window]
ignore_errors = False
disallow_untyped_defs=True
disallow_any_decorated=True
disallow_any_explicit=True
disallow_any_generics=True
disallow_subclassing_any=True

[mypy-parsec.api.*]
ignore_errors = False
disallow_untyped_defs=True
Expand Down
2 changes: 2 additions & 0 deletions newsfragments/1637.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Change the file link URL format so that file path is encrypted.
This change breaks compatibility with previous file url format.
1 change: 0 additions & 1 deletion parsec/api/data/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def make_obj(self, data: Dict[str, Any]) -> "UserManifest":
created: DateTime
updated: DateTime
last_processed_message: int

workspaces: Tuple[WorkspaceEntry, ...] = attr.ib(converter=tuple)

def get_workspace_entry(self, workspace_id: EntryID) -> Optional[WorkspaceEntry]:
Expand Down
1 change: 0 additions & 1 deletion parsec/core/core_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CoreEvent(Enum):
FS_ENTRY_CONFINED = "fs.entry.confined"
FS_ENTRY_UPDATED = "fs.entry.updated"
FS_ENTRY_FILE_CONFLICT_RESOLVED = "fs.entry.file_conflict_resolved"
FS_ENTRY_FILE_UPDATE_CONFLICTED = "fs.entry.file_update_conflicted"
FS_WORKSPACE_CREATED = "fs.workspace.created"
# Gui
GUI_CONFIG_CHANGED = "gui.config.changed"
Expand Down
26 changes: 26 additions & 0 deletions parsec/core/fs/workspacefs/workspacefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import List, Dict, Tuple, AsyncIterator, cast, Pattern, Callable, Optional, Awaitable
from pendulum import DateTime, now as pendulum_now

from parsec.crypto import CryptoError
from parsec.event_bus import EventBus
from parsec.api.data import BaseManifest as BaseRemoteManifest
from parsec.api.data import FileManifest as RemoteFileManifest
Expand All @@ -24,6 +25,7 @@
RemoteWorkspaceManifest,
RemoteFolderishManifests,
DEFAULT_BLOCK_SIZE,
BackendOrganizationFileLinkAddr,
)
from parsec.core.remote_devices_manager import RemoteDevicesManager
from parsec.core.backend_connection import (
Expand Down Expand Up @@ -746,3 +748,27 @@ async def rec(entry_id: EntryID) -> Dict[str, object]:
return result

return await rec(self.workspace_id)

def generate_file_link(self, path: AnyPath) -> BackendOrganizationFileLinkAddr:
"""
Raises: Nothing
"""
workspace_entry = self.get_workspace_entry()
encrypted_path = workspace_entry.key.encrypt(str(FsPath(path)).encode("utf-8"))
return BackendOrganizationFileLinkAddr.build(
organization_addr=self.device.organization_addr,
workspace_id=workspace_entry.id,
encrypted_path=encrypted_path,
)

def decrypt_file_link_path(self, addr: BackendOrganizationFileLinkAddr) -> FsPath:
"""
Raises: ValueError
"""
workspace_entry = self.get_workspace_entry()
try:
raw_path = workspace_entry.key.decrypt(addr.encrypted_path)
except CryptoError:
raise ValueError("Cannot decrypt path")
# FsPath raises ValueError, decode() raises UnicodeDecodeError which is a subclass of ValueError
return FsPath(raw_path.decode("utf-8"))
10 changes: 4 additions & 6 deletions parsec/core/gui/app.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2016-2021 Scille SAS

from parsec.core.core_events import CoreEvent

import sys
import signal
from queue import Queue
from typing import Optional
from contextlib import contextmanager
from enum import Enum

import trio
from structlog import get_logger

from PyQt5.QtCore import QTimer, Qt
from PyQt5.QtWidgets import QApplication

from parsec.core.config import CoreConfig
from parsec.event_bus import EventBus
from parsec.core.core_events import CoreEvent
from parsec.core.config import CoreConfig
from parsec.core.ipcinterface import (
run_ipc_server,
send_to_ipc_server,
Expand Down Expand Up @@ -133,7 +131,7 @@ def log_except(etype, exception, traceback):
sys.excepthook = previous_hook


def run_gui(config: CoreConfig, start_arg: str = None, diagnose: bool = False):
def run_gui(config: CoreConfig, start_arg: Optional[str] = None, diagnose: bool = False):
logger.info("Starting UI")

# Needed for High DPI usage of QIcons, otherwise only QImages are well scaled
Expand Down
Loading

0 comments on commit 2d2dfe2

Please sign in to comment.