Skip to content

Commit 73c5212

Browse files
committed
Adding safeguards for clean and archive commands
1 parent af8c0a2 commit 73c5212

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

jobrunner/cli/_commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Standard libraries
44
from datetime import date
5+
import subprocess
56

67
# Feature libraries
78
import click

jobrunner/lib/_archivetools.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def CreateArchive(config, archive_tag):
6363

6464
# loop over archive_list and archive contents
6565
for filename in archive_list:
66-
shutil.move(filename, nodedir + os.sep + archive_tag)
66+
if os.path.exists(filename + os.sep + "Jobfile"):
67+
print(f'{" "*4}[jobrunner] Cannot archive {filename} SKIPPING')
68+
continue
69+
else:
70+
shutil.move(filename, nodedir + os.sep + archive_tag)
6771

6872
# return back to working directory
6973
os.chdir(config.job.workdir)

jobrunner/lib/_filetools.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ def RemoveNodeFiles(config, nodedir):
248248
if os.path.isfile(filename):
249249
os.remove(filename)
250250
elif os.path.isdir(filename):
251-
shutil.rmtree(filename)
251+
if os.path.exists(filename + os.sep + "Jobfile"):
252+
print(f'{" "*4}[jobrunner] Cannot remove node {filename} SKIPPING')
253+
continue
254+
else:
255+
shutil.rmtree(filename)
252256

253257
# return back to working directory
254258
os.chdir(config.job.workdir)

0 commit comments

Comments
 (0)