[ckan-dev] Rollback when resource creation fails

Martin Burchell martinb-ckan at aptivate.org
Wed Apr 6 11:32:17 UTC 2016


We're writing a plugin to create a dataset and associated resources from 
an uploaded zip file. If a resource fails to be created (for example if 
a file is too large), we want a way to delete the dataset completely so 
that the user can try again. Ideally we'd like to be able to create 
datasets and resources within a transaction but this doesn't seem to be 
possible from the API. Is this correct?

We are generating the dataset names from the meta data in the zip file. 
If we catch the error on resource creation and delete the dataset, the 
dataset ends up in the Trash, which means that when the user tries to 
reimport the dataset, the name will be the same and they will get the 
error "That URL is already in use." We might be able to change the 
deleted dataset to avoid the clash, but this doesn't seem too 
satisfactory a solution.

Can anyone see a better way of doing this?


Best regards,


-- 
Martin Burchell



More information about the ckan-dev mailing list