mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-30 14:00:12 +03:00
Copy config files and database from a previous version if it exists
This commit is contained in:
parent
a20e10f75a
commit
5b00529666
@ -97,8 +97,20 @@ class Config:
|
||||
|
||||
if self._main_config_file is None:
|
||||
|
||||
# TODO: migrate versioned config file from a previous version of GNS3 (for instance 2.2 -> 3.0) + support profiles
|
||||
# migrate post version 2.2.0 config files if they exist
|
||||
if not os.path.exists(versioned_user_dir):
|
||||
# Try to migrate the configuration files and database from the previous version if it exists
|
||||
previous_version = f"{__version_info__[0]}.{int(__version_info__[1]) - 1}"
|
||||
if self._profile:
|
||||
previous_versioned_user_dir = os.path.join(home, ".config", appname, previous_version, "profiles", self._profile)
|
||||
else:
|
||||
previous_versioned_user_dir = os.path.join(home, ".config", appname, previous_version)
|
||||
if os.path.exists(previous_versioned_user_dir):
|
||||
try:
|
||||
shutil.copytree(previous_versioned_user_dir, versioned_user_dir, symlinks=True, ignore_dangling_symlinks=True)
|
||||
log.info(f"Migrated configuration files and database from '{previous_versioned_user_dir}' to '{versioned_user_dir}'")
|
||||
except OSError as e:
|
||||
log.error(f"Cannot migrate old config files and database from '{previous_versioned_user_dir}: {e}")
|
||||
|
||||
os.makedirs(versioned_user_dir, exist_ok=True)
|
||||
try:
|
||||
# migrate the server config file
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user