Skip to content

Commit

Permalink
add condition to copy folders only if the from-to locations differ
Browse files Browse the repository at this point in the history
  • Loading branch information
915-Misan-Teodora committed Dec 4, 2024
1 parent c2edaed commit d4ec169
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tvbextxircuits/start_xircuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ def version_changed():
If they differ, a new version is available.
"""
version_file = Path(os.getcwd()) / '.version'
installed_version = get_extension_version()
running_version = get_extension_version()

if not installed_version:
if not running_version:
LOGGER.error("Not able to retrieve the installed version.")
return

if not version_file.exists():
LOGGER.info("Version file not found.")
return False
return True

try:
stored_version = version_file.read_text().strip()
except Exception as e:
LOGGER.error(f"Error reading version file: {e}")
stored_version = None

return stored_version != installed_version
return stored_version != running_version

def get_extension_version():
"""
Expand Down
10 changes: 6 additions & 4 deletions tvbextxircuits/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def copy_from_installed_wheel(package_name, resource="", dest_path=None, version
config_path = Path(os.getcwd()) / dest_path
# Create the temporary file context
with importlib_resources.as_file(ref) as resource_path:
if not config_path.exists() or version_changed:
if config_path.exists():
shutil.rmtree(config_path)
shutil.copytree(resource_path, dest_path)
dest_path_abs = os.path.abspath(dest_path)
if str(resource_path) != dest_path_abs:
if not config_path.exists() or version_changed:
if config_path.exists():
shutil.rmtree(config_path)
shutil.copytree(resource_path, dest_path)

0 comments on commit d4ec169

Please sign in to comment.