fix path issues on windows

This commit is contained in:
Senko Rasic
2024-05-23 15:24:37 +02:00
parent 38ff65f5a9
commit cdafe2e29e
3 changed files with 4 additions and 3 deletions

View File

@@ -136,7 +136,7 @@ class LocalDiskVFS(VirtualFileSystem):
self.ignore_matcher = ignore_matcher
def get_full_path(self, path: str) -> str:
return os.path.normpath(os.path.join(self.root, path))
return os.path.abspath(os.path.normpath(os.path.join(self.root, path)))
def save(self, path: str, content: str):
full_path = self.get_full_path(path)

View File

@@ -382,8 +382,8 @@ class StateManager:
try:
return LocalDiskVFS(root, allow_existing=load_existing, ignore_matcher=ignore_matcher)
except FileExistsError:
log.warning(f"Directory {root} already exists, changing project folder to {self.project.folder_name}")
self.project.folder_name = self.project.folder_name + "-" + uuid4().hex[:7]
log.warning(f"Directory {root} already exists, changing project folder to {self.project.folder_name}")
await self.current_session.commit()
def get_full_project_root(self) -> str:

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
from os import walk
from os.path import join, relpath
from pathlib import Path
from typing import Any, Callable
from jinja2 import Environment, FileSystemLoader
@@ -93,7 +94,7 @@ class Renderer:
for file in files:
file_path = join(path, file) # actual full path of the template file
tpl_location = relpath(file_path, self.template_dir) # template relative to template_dir
output_location = relpath(file_path, full_root) # template relative to tree root
output_location = Path(file_path).relative_to(full_root).as_posix() # template relative to tree root
if filter:
output_location = filter(output_location)