Avoid storing file in repository if database add failed