Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup: throw error on purge disk space message #744

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pymobiledevice3/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pymobiledevice3.exceptions import AccessDeniedError, ConnectionFailedToUsbmuxdError, DeveloperModeError, \
DeveloperModeIsNotEnabledError, DeviceHasPasscodeSetError, DeviceNotFoundError, InternalError, \
InvalidServiceError, MessageNotSupportedError, MissingValueError, NoDeviceConnectedError, NoDeviceSelectedError, \
NotPairedError, PairingDialogResponsePendingError, PasswordRequiredError, SetProhibitedError, \
TunneldConnectionError, UserDeniedPairingError
NotEnoughDiskSpaceError, NotPairedError, PairingDialogResponsePendingError, PasswordRequiredError, \
SetProhibitedError, TunneldConnectionError, UserDeniedPairingError

coloredlogs.install(level=logging.INFO)

Expand Down Expand Up @@ -143,6 +143,8 @@ def main() -> None:
'sudo python3 -m pymobiledevice3 remote tunneld')
except DeviceNotFoundError as e:
logger.error(f'Device not found: {e.udid}')
except NotEnoughDiskSpaceError:
logger.error('Not enough disk space')


if __name__ == '__main__':
Expand Down
5 changes: 5 additions & 0 deletions pymobiledevice3/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,8 @@ class NoSuchBuildIdentityError(PyMobileDevice3Exception):
class MobileActivationException(PyMobileDevice3Exception):
""" Mobile activation can not be done """
pass


class NotEnoughDiskSpaceError(PyMobileDevice3Exception):
""" Computer does not have enough disk space for the intended operation """
pass
6 changes: 5 additions & 1 deletion pymobiledevice3/services/device_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import warnings
from pathlib import Path

from pymobiledevice3.exceptions import PyMobileDevice3Exception
from pymobiledevice3.exceptions import NotEnoughDiskSpaceError, PyMobileDevice3Exception

SIZE_FORMAT = '>I'
CODE_FORMAT = '>B'
Expand Down Expand Up @@ -40,6 +40,7 @@ def __init__(self, service, root_path: Path):
'DLMessageDownloadFiles': self.download_files,
'DLContentsOfDirectory': self.contents_of_directory,
'DLMessageCopyItem': self.copy_item,
'DLMessagePurgeDiskSpace': self.purge_disk_space
}

def dl_loop(self, progress_callback=lambda x: None):
Expand Down Expand Up @@ -159,6 +160,9 @@ def copy_item(self, message):
shutil.copy(src, dest)
self.status_response(0)

def purge_disk_space(self, message) -> None:
raise NotEnoughDiskSpaceError()

def remove_items(self, message):
for path in message[1]:
rm_path = self.root_path / path
Expand Down
Loading