Skip to content

Commit

Permalink
uploadGeneratetoken: Smarter "create_additional_revision" support
Browse files Browse the repository at this point in the history
Backported from PR midasplatform#146

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
  • Loading branch information
jcfr committed Oct 27, 2015
1 parent b016bf5 commit fc58d0f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/controllers/components/ApisystemComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ function uploadGeneratetoken($args)
$create_additional_revision = isset($args['create_additional_revision']) ? $args['create_additional_revision'] : false;
$revision = $itemModel->getLastRevision($item);

// do not create an additional revision if last revision has one bitstream and checkum matches
if($create_additional_revision && $revision)
{
$bitstreams = $revision->getBitstreams();
if (count($bitstreams) == 1 && $args['checksum'] == $bitstreams[0]->getChecksum())
{
return array('token' => '');
}
}

if($revision == false || $create_additional_revision)
{
// Create new revision if none exists yet or if user explicitly asked for creating a new revision when
Expand Down

0 comments on commit fc58d0f

Please sign in to comment.