Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 25fbe4b

Browse files
committed
uploadGeneratetoken: Smarter "create_additional_revision" support
This commit improves the support for "create_additional_revision" introduced in a previous commit. It will not create an additional revision if last revision has one bitstream and checkum matches
1 parent a0cae4a commit 25fbe4b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/controllers/components/ApisystemComponent.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,14 @@ public function uploadGeneratetoken($args)
411411
$create_additional_revision = isset($args['create_additional_revision']) ? $args['create_additional_revision'] : false;
412412
$revision = $itemModel->getLastRevision($item);
413413

414+
// do not create an additional revision if last revision has one bitstream and checkum matches
415+
if ($create_additional_revision && $revision) {
416+
$bitstreams = $revision->getBitstreams();
417+
if (count($bitstreams) == 1 && $args['checksum'] == $bitstreams[0]->getChecksum()) {
418+
return array('token' => '');
419+
}
420+
}
421+
414422
if ($revision === false || $create_additional_revision) {
415423
// Create new revision if none exists yet or if the user explicitly asked for creating a new revision when
416424
// a bitstream with the same checksum was found.

0 commit comments

Comments
 (0)