aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2020-11-25 11:37:33 +0100
committerGitHub <noreply@github.com>2020-11-25 11:37:33 +0100
commit82864ef8a7adab5195c1e49081c37601ee81ca8f (patch)
tree398371112b6d3bd649921c5499d311e53fa916f3
parent01790537f623ad193308172144216375608b3e0d (diff)
parent12d1c27b7f274c32902ae59483d873861aeed500 (diff)
downloadnextcloud-server-82864ef8a7adab5195c1e49081c37601ee81ca8f.tar.gz
nextcloud-server-82864ef8a7adab5195c1e49081c37601ee81ca8f.zip
Merge pull request #24363 from nextcloud/fix/versions-expire-storage-not-available
Catch storage not available in versions expire command
-rw-r--r--apps/files_versions/lib/Command/Expire.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/files_versions/lib/Command/Expire.php b/apps/files_versions/lib/Command/Expire.php
index 1075314c1c4..bf3400b5018 100644
--- a/apps/files_versions/lib/Command/Expire.php
+++ b/apps/files_versions/lib/Command/Expire.php
@@ -28,6 +28,8 @@ namespace OCA\Files_Versions\Command;
use OC\Command\FileAccess;
use OCA\Files_Versions\Storage;
use OCP\Command\ICommand;
+use OCP\Files\StorageNotAvailableException;
+use OCP\ILogger;
class Expire implements ICommand {
use FileAccess;
@@ -59,6 +61,20 @@ class Expire implements ICommand {
return;
}
- Storage::expire($this->fileName, $this->user);
+ try {
+ Storage::expire($this->fileName, $this->user);
+ } catch (StorageNotAvailableException $e) {
+ // In case of external storage and session credentials, the expiration
+ // fails because the command does not have those credentials
+
+ /** @var ILogger $logger */
+ $logger = \OC::$server->get(ILogger::class);
+
+ $logger->logException($e, [
+ 'level' => ILogger::WARN,
+ 'uid' => $this->user,
+ 'fileName' => $this->fileName,
+ ]);
+ }
}
}
ce */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?php

/**
 * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace Tests\Contacts\ContactsMenu\Actions;

use OC\Contacts\ContactsMenu\Actions\LinkAction;
use Test\TestCase;

class LinkActionTest extends TestCase {
	private LinkAction $action;

	protected function setUp(): void {
		parent::setUp();

		$this->action = new LinkAction();
	}

	public function testSetIcon(): void {
		$icon = 'icon-test';

		$this->action->setIcon($icon);
		$json = $this->action->jsonSerialize();

		$this->assertArrayHasKey('icon', $json);
		$this->assertEquals($json['icon'], $icon);
	}

	public function testGetSetName(): void {
		$name = 'Jane Doe';

		$this->assertEmpty($this->action->getName());
		$this->action->setName($name);
		$this->assertEquals($name, $this->action->getName());
	}

	public function testGetSetPriority(): void {
		$prio = 50;

		$this->assertEquals(10, $this->action->getPriority());
		$this->action->setPriority($prio);
		$this->assertEquals($prio, $this->action->getPriority());
	}

	public function testSetHref(): void {
		$this->action->setHref('/some/url');

		$json = $this->action->jsonSerialize();
		$this->assertArrayHasKey('hyperlink', $json);
		$this->assertEquals('/some/url', $json['hyperlink']);
	}

	public function testJsonSerialize(): void {
		$this->action->setIcon('icon-contacts');
		$this->action->setName('Nickie Works');
		$this->action->setPriority(33);
		$this->action->setHref('example.com');
		$this->action->setAppId('contacts');
		$expected = [
			'title' => 'Nickie Works',
			'icon' => 'icon-contacts',
			'hyperlink' => 'example.com',
			'appId' => 'contacts',
		];

		$json = $this->action->jsonSerialize();

		$this->assertEquals($expected, $json);
	}

	public function testJsonSerializeNoAppName(): void {
		$this->action->setIcon('icon-contacts');
		$this->action->setName('Nickie Works');
		$this->action->setPriority(33);
		$this->action->setHref('example.com');
		$expected = [
			'title' => 'Nickie Works',
			'icon' => 'icon-contacts',
			'hyperlink' => 'example.com',
			'appId' => '',
		];

		$json = $this->action->jsonSerialize();

		$this->assertEquals($expected, $json);
	}
}