completed more

This commit is contained in:
Hellow2 2023-03-30 15:28:23 +02:00
parent fc98998cdb
commit fab76fc165
2 changed files with 22 additions and 0 deletions

View File

@ -51,3 +51,12 @@ class Target(DatabaseObject):
def create_path(self): def create_path(self):
self._path.mkdir(parents=True, exist_ok=True) self._path.mkdir(parents=True, exist_ok=True)
def copy_content(self, copy_to: "Target"):
if not self.exists:
return
with open(self.file_path, "rb") as read_from:
copy_to.create_path()
with open(self.file_path, "wb") as write_to:
write_to.write(read_from.read())

View File

@ -312,6 +312,19 @@ class Page:
if song.target_collection.empty: if song.target_collection.empty:
return return
target: Target
if any(target.exists for target in song.target_collection):
existing_target: Target
for existing_target in song.target_collection:
if existing_target.exists:
break
for target in song.target_collection:
if target is existing_target:
continue
existing_target.copy_content(target)
sources = song.source_collection.get_sources_from_page(cls.SOURCE_TYPE) sources = song.source_collection.get_sources_from_page(cls.SOURCE_TYPE)
if len(sources) == 0: if len(sources) == 0:
return return