Skip to content

Commit

Permalink
fix:gui_caching
Browse files Browse the repository at this point in the history
handle case where dirs already exist
  • Loading branch information
JarbasAl committed Nov 26, 2024
1 parent fc5eef6 commit 6670d01
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ovos_bus_client/apis/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ def _cache_gui_files(self):
for framework, bpath in self.ui_directories.items():
if framework == "all":
# mostly applies to image files
shutil.copytree(bpath, output_path)
shutil.copytree(bpath, output_path, dirs_exist_ok=True)
LOG.debug(f"Copied {self.skill_id} shared GUI resources from {bpath} to {output_path}")
continue
if not os.path.isdir(bpath):
LOG.error(f"invalid '{framework}' resources directory: {bpath}")
continue
shutil.copytree(bpath, f"{output_path}/{framework}")
shutil.copytree(bpath, f"{output_path}/{framework}", dirs_exist_ok=True)
LOG.debug(f"Copied {self.skill_id} GUI resources from {bpath} to {output_path}/{framework}")

def set_bus(self, bus=None):
Expand Down Expand Up @@ -552,11 +552,6 @@ def _resolve_url(self, url: str) -> str:
if url.startswith("http"):
return url

# Sanitize the url to prevent path traversal
url = os.path.normpath(url)
if url.startswith("..") or url.startswith("/"):
return url

if not os.path.isfile(url):
GUI_CACHE_PATH = get_xdg_cache_save_path('ovos_gui')
# Use os.path.join for path construction
Expand Down

0 comments on commit 6670d01

Please sign in to comment.