fix: target mode supports manual tar.gz path input + auto-extract when archive not transferred yet
This commit is contained in:
@@ -145,14 +145,30 @@ def do_restore():
|
||||
|
||||
# Определяем директорию с архивом
|
||||
remote_dir = st.get("target_remote_dir", "/tmp/docker-migrate-incoming")
|
||||
if not os.path.isdir(remote_dir):
|
||||
remote_dir = prompt("Укажите папку с распакованным архивом (manifest + файлы)")
|
||||
|
||||
# Если директория пуста — спрашиваем путь к tar.gz
|
||||
if not os.path.isdir(remote_dir) or not os.listdir(remote_dir):
|
||||
archive_prompt = prompt("Архив не найден в стандартной папке. Укажите путь к .tar.gz архиву (или Enter для указания папки)")
|
||||
if archive_prompt and os.path.isfile(archive_prompt):
|
||||
# Распаковываем tar.gz во временную папку
|
||||
extract_dir = os.path.join(remote_dir, "extracted")
|
||||
run(f"{sudo} mkdir -p {extract_dir}", check=False)
|
||||
run(f"{sudo} tar xzf '{archive_prompt}' -C {extract_dir}", check=False)
|
||||
remote_dir = extract_dir
|
||||
info(f"Архив распакован в: {remote_dir}")
|
||||
elif archive_prompt and os.path.isdir(archive_prompt):
|
||||
remote_dir = archive_prompt
|
||||
else:
|
||||
remote_dir = prompt("Укажите папку с распакованным архивом (manifest + файлы)") or "/tmp/docker-migrate-incoming"
|
||||
if not os.path.isdir(remote_dir):
|
||||
raise RuntimeError(f"Папка не найдена: {remote_dir}")
|
||||
|
||||
manifest_file = None
|
||||
for f in os.listdir(remote_dir):
|
||||
if f.endswith("_manifest.json"):
|
||||
manifest_file = os.path.join(remote_dir, f)
|
||||
break
|
||||
if os.path.isdir(remote_dir):
|
||||
for f in os.listdir(remote_dir):
|
||||
if f.endswith("_manifest.json"):
|
||||
manifest_file = os.path.join(remote_dir, f)
|
||||
break
|
||||
if not manifest_file:
|
||||
raise RuntimeError("manifest.json не найден в папке архива")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user