In Tags::rename($from, $to), check if there already is a tag named $to.
This commit is contained in:
parent
7e9baafc53
commit
226d7233e1
2 changed files with 8 additions and 3 deletions
|
@ -344,9 +344,14 @@ class Tags implements \OCP\ITags {
|
|||
\OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG);
|
||||
return false;
|
||||
}
|
||||
$tag = $this->tags[$key];
|
||||
|
||||
if($this->userHasTag($to, $tag->getOwner())) {
|
||||
\OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', \OCP\Util::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$tag = $this->tags[$key];
|
||||
$tag->setName($to);
|
||||
$this->tags[$key] = $this->mapper->update($tag);
|
||||
} catch(\Exception $e) {
|
||||
|
|
|
@ -150,8 +150,8 @@ class Test_Tags extends PHPUnit_Framework_TestCase {
|
|||
$this->assertTrue($tagger->rename('Wrok', 'Work'));
|
||||
$this->assertTrue($tagger->hasTag('Work'));
|
||||
$this->assertFalse($tagger->hastag('Wrok'));
|
||||
$this->assertFalse($tagger->rename('Wrok', 'Work'));
|
||||
|
||||
$this->assertFalse($tagger->rename('Wrok', 'Work')); // Rename non-existant tag.
|
||||
$this->assertFalse($tagger->rename('Work', 'Family')); // Collide with existing tag.
|
||||
}
|
||||
|
||||
public function testTagAs() {
|
||||
|
|
Loading…
Reference in a new issue