@@ -174,17 +174,11 @@ def distribution_extra_fields(self, repository, upstream_distribution):
174174 """
175175 Return the fields that need to be updated/cleared on distributions for idempotence.
176176
177- Note: repository_version is computed here but filtered out for updates/creates.
178- It will be set atomically in finalize_replication after sync completes .
177+ Note: repository_version is NOT included here. It is set atomically in
178+ finalize_replication after all syncs complete .
179179 """
180- latest = repository .latest_version ()
181- if latest :
182- repo_version_href = get_url (repository ) + "versions/{}/" .format (latest .number )
183- else :
184- repo_version_href = None
185180 return {
186181 "repository" : None ,
187- "repository_version" : repo_version_href ,
188182 "publication" : None ,
189183 "base_path" : upstream_distribution ["base_path" ],
190184 }
@@ -198,32 +192,26 @@ def create_or_update_distribution(self, repository, upstream_distribution):
198192 )
199193 if not self ._is_managed (distro ):
200194 return None
201- # Don't update repository_version here — that happens atomically in
202- # finalize_replication after all syncs complete.
203- # Do clear repository and publication so they don't conflict.
204- update_data = {k : v for k , v in distribution_data .items () if k != "repository_version" }
205- needs_update = self .needs_update (update_data , distro )
195+ # Clear repository and publication so they don't conflict when
196+ # finalize_replication sets repository_version atomically.
197+ needs_update = self .needs_update (distribution_data , distro )
206198 if needs_update :
207- # Update the distribution
208199 dispatch (
209200 ageneral_update ,
210201 task_group = self .task_group ,
211202 shared_resources = [repository , self .server ],
212203 exclusive_resources = self .distros_uris ,
213204 args = (distro .pk , self .app_label , self .distribution_serializer_name ),
214205 kwargs = {
215- "data" : update_data ,
206+ "data" : distribution_data ,
216207 "partial" : True ,
217208 },
218209 )
219210 except self .distribution_model_cls .DoesNotExist :
220- # Dispatch a task to create the distribution
221- # Don't set repository_version for new distributions - it will be set in
222- # finalize_replication after sync completes.
211+ # Don't set repository or publication for new distributions —
212+ # repository_version will be set in finalize_replication after sync completes.
223213 create_data = {
224- k : v
225- for k , v in distribution_data .items ()
226- if k not in ("repository_version" , "repository" , "publication" )
214+ k : v for k , v in distribution_data .items () if k not in ("repository" , "publication" )
227215 }
228216 create_data ["name" ] = upstream_distribution ["name" ]
229217 create_data ["pulp_labels" ] = distribution_data ["pulp_labels" ]
0 commit comments