From 8c9fe445466130f9110af1e848a9a6150b4a839d Mon Sep 17 00:00:00 2001 From: Vincent Zeng Date: Thu, 22 Mar 2018 12:55:04 -0400 Subject: [PATCH] feels archive copies over files --- ttbp/core.py | 6 ++++-- ttbp/ttbp.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ttbp/core.py b/ttbp/core.py index 1a54aea..3b9730a 100644 --- a/ttbp/core.py +++ b/ttbp/core.py @@ -487,7 +487,8 @@ def unpublish_feel(filename): subprocess.call(["rm", live_gopher]) def process_backup(filename): - """takes given filename and loads the archive into current main feels. + """takes given filename and unpacks it into a temp directory, then returns a + list of filenames with collisions filtered out. ignores any invalidly named files or files that already exist, to avoid clobbering current feels. ignored files are left in the archive directory @@ -509,8 +510,9 @@ def process_backup(filename): for feel in backups: if os.path.basename(feel) not in current: - imported.append(feel) + imported.append(os.path.join(backup_entries, feel)) + imported.sort() return imported def import_feels(backups): diff --git a/ttbp/ttbp.py b/ttbp/ttbp.py index 3bbbeb6..37e6bb4 100644 --- a/ttbp/ttbp.py +++ b/ttbp/ttbp.py @@ -1022,7 +1022,8 @@ def load_backup(): if len(backups) < 1: print("""" sorry, i didn't find any feels backups! if you have a backup file handy, please -move it to {directory} and try running this tool again.""".format(directory=config.BACKUPS)) +move it to {directory} and try running this tool again.\ +""".format(directory=config.BACKUPS)) else: print("backup files found:\n") choice = menu_handler(backups, "pick a backup file to load (or 'q' to cancel): ", 15, SETTINGS.get("rainbows", False), "backup files found:") @@ -1030,12 +1031,13 @@ move it to {directory} and try running this tool again.""".format(directory=conf if choice is not False: imports = core.process_backup(os.path.join(config.BACKUPS, backups[choice])) for feel in imports: - print("importing {feel}".format(feel="-".join(util.parse_date(feel)))) + print("importing {entry}".format(entry="-".join(util.parse_date(feel)))) + subprocess.call(["mv", feel, config.MAIN_FEELS]) time.sleep(.01) tempdir = os.path.join(config.BACKUPS, os.path.splitext(os.path.splitext(os.path.basename(backups[choice]))[0])[0], "entries") - if len(imports) == len(os.listdir(tempdir)): + if len(os.listdir(tempdir)) == 0: print("congrats! your feels archive has been unloaded.") else: print("""\