def_tests_reworked #88
No reviewers
Labels
No Label
Bug
Contributions welcome
Did not do
Duplicate
Feature
Module
Backups
Module
GraphQL
Priority
High
Priority
Low
Priority
Medium
Refactor
Severity
High
Severity
Low
Severity
Medium
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: SelfPrivacy/selfprivacy-rest-api#88
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "def_tests_reworked"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
It also contains a complete refactor of service mover.
Closes #17
@ -198,3 +198,3 @@
return ServiceJobMutationReturn(
success=False,
message=f"Service move failure: {job.status_text}",
message=f"Service move failure: {job.status_text}: {job.error}",
Double usage of
:
in one sentence.@ -50,2 +56,2 @@
folder_names: list[FolderMoveNames],
userdata_location: str,
folder_names: List[FolderMoveNames],
userdata_location: str = None, # deprecated, not used
None cannot be assigned to str. Probably refactor all usages to remove the argument?
@ -59,3 +63,2 @@
service_name = service.get_display_name()
with ReadUserData() as user_data:
if not user_data.get("useBinds", False):
old_volume = service.get_drive()
It is a string, but used like it is a BlockDevice
@ -76,1 +106,3 @@
return
def check_volume(new_volume: BlockDevice, service: Service) -> bool:
This function doesn't return bool
@ -183,2 +164,3 @@
progress=current_progress + folder_percentage,
f"/volumes/{new_volume.name}/{folder.name}",
)
progress = current_progress + folder_percentage
Job's progress is Optional[int], so the current_progress might turn out to be None
Probably, the Job.progress type should be changed instead
@ -246,1 +210,4 @@
def update_volume_in_userdata(service: Service, volume: BlockDevice):
with WriteUserData() as user_data:
service_id = service.get_id()
Probably it is better to be outside of the WriteUserData context
e23d5da84f
to5cb2151a28
@ -0,0 +32,4 @@
handle = move_service_task(service, volume, job)
# Nonblocking
handle()
Black magic
@ -5,18 +5,25 @@ import strawberry
from selfprivacy_api.graphql import IsAuthenticated
from selfprivacy_api.graphql.common_types.jobs import job_to_api_job
from selfprivacy_api.jobs import JobStatus
from selfprivacy_api.utils.block_devices import BlockDevices
Unused import
@ -17,0 +21,4 @@
ServiceNotFoundError,
VolumeNotFoundError,
)
from selfprivacy_api.services.moving import MoveError
Unused import
@ -268,6 +268,18 @@ class Jobs:
return False
# A terse way to call a common operation, for readability
Why not a docstring here?
@ -0,0 +29,4 @@
raise MoveError("Volume is not mounted.")
def check_folders(current_volume: BlockDevice, folders: List[OwnedPath]) -> None:
current_volume
declared asBlockDevice
but used and passed asstr
@ -0,0 +55,4 @@
def move_folders_to_volume(
folders: List[OwnedPath],
old_volume_name: str, # TODO: pass an actual validated block device
at least two spaces before inline comment: Flake8(E261)
@ -13,3 +22,4 @@
from selfprivacy_api import utils
from selfprivacy_api.utils.waitloop import wait_until_true
from selfprivacy_api.utils import ReadUserData, WriteUserData, get_domain
get_domain
is unused@ -272,0 +335,4 @@
report_progress(70, job, f"Making sure {service_name} owns its files...")
try:
ensure_folder_ownership(owned_folders, new_volume, job, self)
Too many arguments
9b4617fdbf
tocf7c7f168a
cf7c7f168a
to26a1b298c4
769ca07594
toee7c41e0c2