fix: correct method names for Path
This commit is contained in:
parent
a805d2a0e8
commit
e1e34def8c
1 changed files with 4 additions and 9 deletions
|
|
@ -226,17 +226,12 @@ class InstallableExtension(BaseModel):
|
||||||
def has_installed_version(self) -> bool:
|
def has_installed_version(self) -> bool:
|
||||||
if not self.ext_dir.is_dir():
|
if not self.ext_dir.is_dir():
|
||||||
return False
|
return False
|
||||||
config_file = Path(self.ext_dir, "config.json")
|
return Path(self.ext_dir, "config.json").is_file()
|
||||||
if not config_file.is_file():
|
|
||||||
return False
|
|
||||||
with open(config_file, "r") as json_file:
|
|
||||||
config_json = json.load(json_file)
|
|
||||||
return config_json.get("is_installed") is True
|
|
||||||
|
|
||||||
def download_archive(self):
|
def download_archive(self):
|
||||||
logger.info(f"Downloading extension {self.name}.")
|
logger.info(f"Downloading extension {self.name}.")
|
||||||
ext_zip_file = self.zip_path
|
ext_zip_file = self.zip_path
|
||||||
if ext_zip_file.isfile():
|
if ext_zip_file.is_file():
|
||||||
os.remove(ext_zip_file)
|
os.remove(ext_zip_file)
|
||||||
try:
|
try:
|
||||||
download_url(self.installed_release.archive, ext_zip_file)
|
download_url(self.installed_release.archive, ext_zip_file)
|
||||||
|
|
@ -250,7 +245,7 @@ class InstallableExtension(BaseModel):
|
||||||
archive_hash = file_hash(ext_zip_file)
|
archive_hash = file_hash(ext_zip_file)
|
||||||
if self.installed_release.hash and self.installed_release.hash != archive_hash:
|
if self.installed_release.hash and self.installed_release.hash != archive_hash:
|
||||||
# remove downloaded archive
|
# remove downloaded archive
|
||||||
if ext_zip_file.isfile():
|
if ext_zip_file.is_file():
|
||||||
os.remove(ext_zip_file)
|
os.remove(ext_zip_file)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND,
|
status_code=HTTPStatus.NOT_FOUND,
|
||||||
|
|
@ -310,7 +305,7 @@ class InstallableExtension(BaseModel):
|
||||||
|
|
||||||
def clean_extension_files(self):
|
def clean_extension_files(self):
|
||||||
# remove downloaded archive
|
# remove downloaded archive
|
||||||
if self.zip_path.isfile():
|
if self.zip_path.is_file():
|
||||||
os.remove(self.zip_path)
|
os.remove(self.zip_path)
|
||||||
|
|
||||||
# remove module from extensions
|
# remove module from extensions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue