Skip to content

Commit

Permalink
Fixes a download issue where it downloaded files to the base of custo…
Browse files Browse the repository at this point in the history
…m_components
  • Loading branch information
ludeeus committed Jun 3, 2019
1 parent c2ffa78 commit 4b914b8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/hacs/hacsrepositorybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ async def download_repository_directory_content(self, repository_directory_path,
for content_object in contents:
if content_object.type == "dir":
await self.download_repository_directory_content(content_object.path, local_directory, ref)
continue
if self.repository_type == "plugin" and not content_object.name.endswith(".js"):
# For plugins we currently only need .js files
continue
Expand All @@ -171,17 +172,17 @@ async def download_repository_directory_content(self, repository_directory_path,
# Save the content of the file.
if self.repository_name == "custom-components/hacs":
local_directory = "{}/{}".format(self.config_dir, content_object.path)
local_directory = local_directory.split(".")[0]
strip = local_directory.split("/")[-1]
local_directory = local_directory.split("/{}".format(strip))[0]
local_directory = local_directory.split("/{}".format(content_object.name))[0]
_LOGGER.debug(content_object.path)
_LOGGER.debug(local_directory)

# Check local directory
pathlib.Path(local_directory).mkdir(parents=True, exist_ok=True)

local_file_path = "{}/{}".format(local_directory, content_object.name)
await async_save_file(local_file_path, filecontent)

except SystemError as exception:
except Exception as exception:
_LOGGER.debug(exception)

async def install(self):
Expand Down

0 comments on commit 4b914b8

Please sign in to comment.