Commit 676c6099 authored by Marko Kuder's avatar Marko Kuder
Browse files

remove_revisions: ignore protocol or domain changes on uploaded resources

parent 300044d3
......@@ -38,7 +38,15 @@ class RemoveRevisions(CkanCommand):
def are_equal(self, old_revision, new_revision):
equal = True
for attr in self.attributes:
if getattr(old_revision, attr) != getattr(new_revision, attr):
if attr == 'url' and getattr(old_revision, 'url_type') == 'upload' and getattr(new_revision, 'url_type') == 'upload':
#compare without protocol prefix and domain, because on uploaded file url generation,
#some plugins might change http into https or localhost might be stored instead of site url
old_url = getattr(old_revision, attr).split('//',1)[-1].split('/',1)[-1]
new_url = getattr(new_revision, attr).split('//',1)[-1].split('/',1)[-1]
if old_url != new_url:
equal = False
elif getattr(old_revision, attr) != getattr(new_revision, attr):
equal = False
return equal
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment