aboutsummaryrefslogtreecommitdiff
path: root/brep/handler/submit/submit-pub.in
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-04-04 20:34:20 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-04-04 22:48:11 +0300
commitb8f351516e4c8cabe808c13e3e47e35ccddc4571 (patch)
tree3246ba5cca9b8fba20e74ec810658d00b172f14f /brep/handler/submit/submit-pub.in
parent92ce9a3681fa939f1b39326abad62bb264bcd6ac (diff)
Fix submit-pub handler to deny submission of older package version revision
Diffstat (limited to 'brep/handler/submit/submit-pub.in')
-rw-r--r--brep/handler/submit/submit-pub.in17
1 files changed, 17 insertions, 0 deletions
diff --git a/brep/handler/submit/submit-pub.in b/brep/handler/submit/submit-pub.in
index ea12a29..f4a3c2d 100644
--- a/brep/handler/submit/submit-pub.in
+++ b/brep/handler/submit/submit-pub.in
@@ -257,6 +257,8 @@ else
message_suffix=": $name/$version"
fi
+revision="$(version_revision "$version")"
+
# Open the reading file descriptor and lock the repository. Fail if unable to
# lock before timeout.
#
@@ -330,9 +332,24 @@ run rsync -rtO --exclude 'packages.manifest' --link-dest="$repo_old" \
# Remove the package version revision archives that may exist in the
# repository.
#
+# But first check if the repository contains newer revision of this package
+# version. Respond with the 'newer revision is present' result manifest and
+# exit if that's the case.
+#
run pkg_find_archives "$name" "$version*" "$repo_new/1" | readarray -t arcs
for f in "${arcs[@]}"; do
+ pkg_verify_archive "$f" | readarray -t p
+
+ v="${p[1]}"
+ rv="$(version_revision "$v")"
+
+ if [ "$rv" -gt "$revision" ]; then
+ exit_with_manifest 422 "newer revision $name/$v is present"
+ fi
+done
+
+for f in "${arcs[@]}"; do
run rm "$f"
done