HotFix to delete a resource during an iRODS failure.
@@ -4,6 +4,7 @@ import errno
import tempfile
import mimetypes
import zipfile
+import logging
from foresite import utils, Aggregation, AggregatedResource, RdfLibSerializer
from rdflib import Namespace, URIRef
@@ -27,11 +28,19 @@ def delete_files_and_bag(resource):
istorage = resource.get_irods_storage()
# delete resource directory first to remove all generated bag-related files for the resource
+ try:
if istorage.exists(resource.root_path):
istorage.delete(resource.root_path)
+ except Exception as e:
+ logger = logging.getLogger(__name__)
+ logger.error("cannot remove {}: {}".format(resource.root_path, e))
+ try:
if istorage.exists(resource.bag_path):
istorage.delete(resource.bag_path)
+ except Exception as e:
+ logger = logging.getLogger(__name__)
+ logger.error("cannot remove {}: {}".format(resource.bag_path, e))
# TODO: delete this whole mechanism; redundant.
# delete the bags table
