From aa5a674a17e414d4fdb2cb17f183ac3e24d6b42c Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sun, 10 Jun 2018 23:01:56 -0400 Subject: [PATCH] add new migrate_data step to move old folder --- archiver/archive.py | 4 ++++ archiver/util.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/archiver/archive.py b/archiver/archive.py index 5da9325f..c795b316 100755 --- a/archiver/archive.py +++ b/archiver/archive.py @@ -7,6 +7,7 @@ import os import sys from datetime import datetime +from subprocess import run from parse import parse_links from links import validate_links @@ -29,6 +30,7 @@ from util import ( progress, cleanup_archive, pretty_path, + migrate_data, ) __AUTHOR__ = 'Nick Sweeting ' @@ -124,6 +126,8 @@ if __name__ == '__main__': print_help() raise SystemExit(0) + migrate_data() + source = sys.argv[1] if argc > 1 else None # path of links file to import resume = sys.argv[2] if argc > 2 else None # timestamp to resume dowloading from diff --git a/archiver/util.py b/archiver/util.py index 793bbcc7..315daddc 100644 --- a/archiver/util.py +++ b/archiver/util.py @@ -360,6 +360,14 @@ def fix_folder_path(archive_path, link_folder, link): run(['rm', '-R', source]) +def migrate_data(): + # migrate old folder to new OUTPUT folder + old_dir = os.path.join(REPO_DIR, 'html') + if os.path.exists(old_dir): + print('[!] WARNING: Moved old output folder "html" to new location: {}'.format(OUTPUT_DIR)) + run(['mv', old_dir, OUTPUT_DIR], timeout=10) + + def cleanup_archive(archive_path, links): """move any incorrectly named folders to their canonical locations"""