Skip to content

Commit

Permalink
paquo.projects: speedup add_image if project contains multiple images
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- committed Jul 15, 2021
1 parent 7294f5b commit 7699893
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions paquo/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ def add_image(self,
if image_type is not None:
py_entry.image_type = image_type
# save project after adding image
self.save()
py_entry.save()
self.save(images=False)
return py_entry

def is_readable(self) -> Dict[Hashable, bool]:
Expand Down Expand Up @@ -415,15 +416,16 @@ def path(self) -> pathlib.Path:
return pathlib.Path(str(self.java_object.getPath()))

@redirect(stderr=True, stdout=True)
def save(self) -> None:
def save(self, images=True) -> None:
"""flush changes in the project to disk
(writes path_classes and project data)
"""
if self._readonly:
raise IOError("project in readonly mode")
for entry in self.images:
entry.save()
if images:
for entry in self.images:
entry.save()
try:
self.java_object.syncChanges()
# convert java land exception
Expand Down

0 comments on commit 7699893

Please sign in to comment.