From d758599208817704069eb9f948c045c4f90f9213 Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Thu, 25 Sep 2025 10:44:23 +0200 Subject: [PATCH] Only delete problem zip after detecting problem directory Otherwise, if you only have the zip, it gets deleted and then the script fails, leaving you without the data of that problem. In my case, I didn't notice, and ran `import-contest` again after unzipping all problem archives, which then failed because the first problem was missing. --- misc-tools/import-contest.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc-tools/import-contest.in b/misc-tools/import-contest.in index cb940e2334..dd999ad3e4 100755 --- a/misc-tools/import-contest.in +++ b/misc-tools/import-contest.in @@ -216,11 +216,11 @@ if os.path.exists('problems.yaml') or os.path.exists('problems.json') or os.path confirmIndividually = dj_utils.confirm("Confirm individually for every problem", False) for problem in problems: print(f'\nPreparing problem \'{problem}\'.') - if os.path.exists(f'{problem}.zip'): - os.unlink(f'{problem}.zip') if not os.path.isdir(problem) or not os.path.isfile(f'{problem}/problem.yaml'): print('Problem directory not found or doesn\'t contain a problem.yaml.') exit(3) + if os.path.exists(f'{problem}.zip'): + os.unlink(f'{problem}.zip') zip_command = f"zip -r '../{problem}' -- .timelimit *" process = subprocess.Popen(zip_command, cwd=problem, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, shell=True)