Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: skip unresolvable symlinks when listing files #256

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions reana_workflow_controller/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# under the terms of the MIT License; see LICENSE file for more details.
"""Workflow persistence management."""

import logging
import os
from pathlib import Path

Expand Down Expand Up @@ -50,11 +51,19 @@ def list_directory_files(directory):
fs_ = fs.open_fs(directory)
file_list = []
for file_name in fs_.walk.files():
file_details = fs_.getinfo(file_name, namespaces=['details'])
file_list.append({'name': file_name.lstrip('/'),
'last-modified': file_details.modified.
strftime(WORKFLOW_TIME_FORMAT),
'size': file_details.size})
try:
file_details = fs_.getinfo(file_name, namespaces=['details'])
file_list.append({'name': file_name.lstrip('/'),
'last-modified': file_details.modified
.strftime(WORKFLOW_TIME_FORMAT),
'size': file_details.size})
except fs.errors.ResourceNotFound as e:
if os.path.islink(fs_.root_path + file_name):
target = os.path.realpath(fs_.root_path + file_name)
msg = 'Symbolic link {} targeting {} could not be resolved: \
{}'.format(file_name, target, e)
logging.error(msg, exc_info=True)
continue
return file_list


Expand Down