提交 ffb1ef5d 编写于 作者: C Cleber Rosa

latest job result: avoid playing with latest if it's not a symlink

This adds a safety check and prevents Avocado from accidentaly
deleting a regular file, not a symlink, that is named `latest`.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 21895c43
......@@ -232,6 +232,8 @@ def update_latest_job_logs_dir(job_result_dir):
basedir = os.path.dirname(job_result_dir)
basename = os.path.basename(job_result_dir)
latest = os.path.join(basedir, "latest")
if os.path.exists(latest) and not os.path.islink(latest):
raise OSError('"%s" already exists and is not a symlink' % latest)
try:
os.unlink(latest)
except OSError:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册