add logic to find hanging files
@@ -109,22 +109,16 @@ def check_irods_files(resource, stop_on_error=False, log_errors=True,
from hs_composite_resource.models import CompositeResource as CR
if isinstance(resource, CR):
for lf in resource.logical_files:
- if not istorage.exists(lf.metadata_file_path):
+ for f in lf.files.all():
+ try:
+ f.resource_file.size
+ except:
ecount += 1
- msg = "check_irods_files: logical metadata file {} does not exist in iRODS"\
- .format(lf.metadata_file_path)
- if echo_errors:
+ msg = "check_resource: file {} does not exist on irods" \
+ .format(f.storage_path.encode('ascii', 'replace'))
print(msg)
- if log_errors:
- logger.error(msg)
- if return_errors:
- errors.append(msg)
- if stop_on_error:
- raise ValidationError(msg)
- if not istorage.exists(lf.map_file_path):
- ecount += 1
- msg = "check_irods_files: logical map file {} does not exist in iRODS"\
- .format(lf.map_file_path)
+ if clean_django:
+ f.delete()
if echo_errors:
print(msg)
if log_errors:
@@ -133,7 +127,6 @@ def check_irods_files(resource, stop_on_error=False, log_errors=True,
errors.append(msg)
if stop_on_error:
raise ValidationError(msg)
-
# Step 4: does every iRODS file correspond to a record in files?
error2, ecount2 = __check_irods_directory(resource, resource.file_path, logger,
stop_on_error=stop_on_error,
