File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -749,11 +749,22 @@ async def refresh(
749749 }
750750
751751 # Compute the difference btw resources needed and the existing resources
752- resources_to_update = [
753- resource for resource in charm_resources
754- if resource .get ('Name' , resource .get ('name' )) not in existing_resources or
755- existing_resources [resource .get ('Name' , resource .get ('name' ))].origin != 'upload'
756- ]
752+ resources_to_update = []
753+ for resource in charm_resources :
754+ # should upgrade resource?
755+ res_name = resource .get ('Name' , resource .get ('name' ))
756+ # no, if it's upload
757+ if existing_resources [res_name ].origin == 'upload' :
758+ continue
759+
760+ # no, if we already have it (and upstream doesn't have a newer res available)
761+ if res_name in existing_resources :
762+ available_rev = resource ['revision' ]
763+ existing_rev = existing_resources [res_name ].unknown_fields .get ('revision' , - 1 )
764+ if existing_rev >= available_rev :
765+ continue
766+
767+ resources_to_update .append (resource )
757768
758769 # Update the resources
759770 if resources_to_update :
You can’t perform that action at this time.
0 commit comments