[BUGFIX] Clear working directory before starting any downloads
This commit is contained in:
parent
96e741c71d
commit
df88ae99ba
1 changed files with 5 additions and 3 deletions
|
|
@ -95,8 +95,9 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
entry=entry,
|
entry=entry,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _delete_working_directory(self, is_error: bool) -> None:
|
def _delete_working_directory(self, is_error: bool = False) -> None:
|
||||||
_ = is_error
|
_ = is_error
|
||||||
|
if os.path.isdir(self.working_directory):
|
||||||
shutil.rmtree(self.working_directory)
|
shutil.rmtree(self.working_directory)
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
|
@ -105,6 +106,7 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
Context manager to create all directories to the working directory. Deletes the entire
|
Context manager to create all directories to the working directory. Deletes the entire
|
||||||
working directory when cleaning up.
|
working directory when cleaning up.
|
||||||
"""
|
"""
|
||||||
|
self._delete_working_directory()
|
||||||
os.makedirs(self.working_directory, exist_ok=True)
|
os.makedirs(self.working_directory, exist_ok=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -113,7 +115,7 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
||||||
self._delete_working_directory(is_error=True)
|
self._delete_working_directory(is_error=True)
|
||||||
raise exc
|
raise exc
|
||||||
else:
|
else:
|
||||||
self._delete_working_directory(is_error=False)
|
self._delete_working_directory()
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _maintain_archive_file(self):
|
def _maintain_archive_file(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue