1
0
mirror of https://github.com/vladmandic/sdnext.git synced 2026-01-27 15:02:48 +03:00
Files
sdnext/modules/migrate.py
vladmandic a7c32caae3 relocate all jsons to data
Signed-off-by: vladmandic <mandic00@live.com>
2026-01-24 13:54:40 +01:00

37 lines
1.1 KiB
Python

import os
from modules.paths import data_path
from installer import log
files = [
'cache.json',
'metadata.json',
'html/extensions.json',
'html/previews.json',
'html/upscalers.json',
'html/reference.json',
'html/themes.json',
'html/reference-quant.json',
'html/reference-distilled.json',
'html/reference-community.json',
'html/reference-cloud.json',
]
def migrate_data():
for f in files:
old_filename = os.path.join(data_path, f)
new_filename = os.path.join(data_path, "data", os.path.basename(f))
if os.path.exists(old_filename):
if not os.path.exists(new_filename):
log.info(f'Migrating: file="{old_filename}" target="{new_filename}"')
try:
os.rename(old_filename, new_filename)
except Exception as e:
log.error(f'Migrating: file="{old_filename}" target="{new_filename}" {e}')
else:
log.warning(f'Migrating: file="{old_filename}" target="{new_filename}" skip existing')
migrate_data()