File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -740,11 +740,22 @@ async def refresh(
740740 }
741741
742742 # Compute the difference btw resources needed and the existing resources
743- resources_to_update = [
744- resource for resource in charm_resources
745- if resource .get ('Name' , resource .get ('name' )) not in existing_resources or
746- existing_resources [resource .get ('Name' , resource .get ('name' ))].origin != 'upload'
747- ]
743+ resources_to_update = []
744+ for resource in charm_resources :
745+ # should upgrade resource?
746+ res_name = resource .get ('Name' , resource .get ('name' ))
747+ # no, if it's upload
748+ if existing_resources [res_name ].origin == 'upload' :
749+ continue
750+
751+ # no, if we already have it (and upstream doesn't have a newer res available)
752+ if res_name in existing_resources :
753+ available_rev = resource ['revision' ]
754+ existing_rev = existing_resources [res_name ].unknown_fields .get ('revision' , - 1 )
755+ if existing_rev >= available_rev :
756+ continue
757+
758+ resources_to_update .append (resource )
748759
749760 # Update the resources
750761 if resources_to_update :
You can’t perform that action at this time.
0 commit comments