Add comprehensive ref_count tests and fix resumable upload double-counting bug
- Add tests for cascade deletion ref_count (package/project delete) - Add tests for tag update ref_count adjustments - Fix resumable upload bug where ref_count was incremented manually AND by SQL trigger - ref_count is now exclusively managed by SQL triggers on tag INSERT/DELETE/UPDATE
This commit is contained in:
@@ -1167,8 +1167,12 @@ def init_resumable_upload(
|
||||
db.query(Artifact).filter(Artifact.id == init_request.expected_hash).first()
|
||||
)
|
||||
if existing_artifact:
|
||||
# File already exists - use atomic increment for ref count
|
||||
_increment_ref_count(db, existing_artifact.id)
|
||||
# File already exists - deduplicated upload
|
||||
# NOTE: ref_count is managed by SQL triggers on tag INSERT/DELETE/UPDATE
|
||||
# We do NOT manually increment here because:
|
||||
# 1. If a tag is provided, _create_or_update_tag will create/update a tag
|
||||
# and the SQL trigger will handle ref_count
|
||||
# 2. If no tag is provided, ref_count shouldn't change (no new reference)
|
||||
|
||||
# Record the upload
|
||||
upload = Upload(
|
||||
|
||||
Reference in New Issue
Block a user