Skip to content

Commit 0b585ee

Browse files
committed
move file size to consts
1 parent 92d5340 commit 0b585ee

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

mergin/client_push.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,6 @@ def get_push_changes_batch(mc, mp: MerginProject) -> Tuple[LocalProjectChanges,
495495
)
496496
except ChangesValidationError as e:
497497
raise ClientError(
498-
f"Some files exceeded maximum upload size. Files: {', '.join([c.path for c in e.invalid_changes])}. Maximum size for media files is {e.max_media_upload_size / (1024**3)} GB and for geopackage files {e.max_versioned_upload_size / (1024**3)} GB."
498+
f"Some files exceeded maximum upload size. Files: {', '.join([c.path for c in e.invalid_changes])}. Maximum size for media files is {MAX_UPLOAD_MEDIA_SIZE / (1024**3)} GB and for geopackage files {MAX_UPLOAD_VERSIONED_SIZE / (1024**3)} GB."
499499
)
500500
return local_changes, sum(len(v) for v in changes.values())

mergin/local_changes.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
# The custom exception
1212
class ChangesValidationError(Exception):
13-
def __init__(self, message, invalid_changes=[], max_media_upload_size=None, max_versioned_upload_size=None):
13+
def __init__(self, message, invalid_changes=[]):
1414
super().__init__(message)
1515
self.invalid_changes = invalid_changes if invalid_changes is not None else []
16-
self.max_media_upload_size = max_media_upload_size
17-
self.max_versioned_upload_size = max_versioned_upload_size
1816

1917

2018
@dataclass
@@ -96,8 +94,6 @@ def __post_init__(self):
9694
oversize_changes.append(change)
9795
if oversize_changes:
9896
error = ChangesValidationError("Some files exceed the maximum upload size", oversize_changes)
99-
error.max_media_upload_size = MAX_UPLOAD_MEDIA_SIZE
100-
error.max_versioned_upload_size = MAX_UPLOAD_VERSIONED_SIZE
10197
raise error
10298

10399
if total_changes > MAX_UPLOAD_CHANGES:

mergin/merginproject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
conflicted_copy_file_name,
2222
edit_conflict_file_name,
2323
)
24-
from .local_changes import LocalChange
24+
from .local_changes import FileChange
2525

2626
this_dir = os.path.dirname(os.path.realpath(__file__))
2727

@@ -470,7 +470,7 @@ def get_push_changes(self):
470470
changes["updated"] = [f for f in changes["updated"] if f not in not_updated]
471471
return changes
472472

473-
def copy_versioned_file_for_upload(self, f: LocalChange, tmp_dir: str) -> str:
473+
def copy_versioned_file_for_upload(self, f: FileChange, tmp_dir: str) -> str:
474474
"""
475475
Make a temporary copy of the versioned file using geodiff, to make sure that we have full
476476
content in a single file (nothing left in WAL journal)

0 commit comments

Comments
 (0)