Full antibugging for ResourceFile.create
@@ -1941,22 +1941,32 @@ class ResourceFile(models.Model):
else: # if file is not an open file, then it's a basename (string)
if file is None and source is not None:
+ if __debug__:
+ assert(isinstance(source, baseString))
# source is a path to an iRODS file to be copied here.
root, newfile = os.path.split(source) # take file from source path
# newfile is where it should be copied to.
target = get_resource_file_path(resource, newfile, folder=folder)
istorage = resource.get_irods_storage()
+ if __debug__:
+ if not istorage.exists(source):
+ raise ValidationError("ResourceFile.create: source {} of copy not found"
+ .format(source))
if not move:
istorage.copyFiles(source, target)
else:
istorage.moveFile(source, target)
+ if __debug__:
if not istorage.exists(target):
raise ValidationError("ResourceFile.create: copy to target {} failed"
.format(target))
+ if move and istorage.exists(source):
+ raise ValidationError("ResourceFile.create: move did not work")
elif file is not None and source is None:
# file points to an existing iRODS file
target = get_resource_file_path(resource, file, folder=folder)
istorage = resource.get_irods_storage()
+ if __debug__:
if not istorage.exists(target):
raise ValidationError("ResourceFile.create: target {} does not exist"
.format(target))
