Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-01-23 16:18:06 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-01-23 16:18:06 +0300
commit19418917bd370af9edd756d10eeeafe2b966e6e5 (patch)
treedf7acee88848d07ab7d8307e672b1acca6436e26 /lib/Migration
parentc8d90e539cb0ac41d23eee31e5d869201d5b71f7 (diff)
Make the itinerary extractor executable in a repair step
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Migration')
-rw-r--r--lib/Migration/MakeItineraryExtractorExecutable.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/Migration/MakeItineraryExtractorExecutable.php b/lib/Migration/MakeItineraryExtractorExecutable.php
new file mode 100644
index 000000000..a1efe387c
--- /dev/null
+++ b/lib/Migration/MakeItineraryExtractorExecutable.php
@@ -0,0 +1,75 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OCA\Mail\Migration;
+
+use OCP\ILogger;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+use Throwable;
+use function chmod;
+use function is_executable;
+use function is_file;
+
+class MakeItineraryExtractorExecutable implements IRepairStep {
+
+ /** @var ILogger */
+ private $logger;
+
+ /** @var string */
+ private $file;
+
+ public function __construct(ILogger $logger,
+ string $file = null) {
+ $this->file = $file ?? __DIR__ . '/../../vendor/christophwurst/kitinerary-bin/bin/kitinerary-extractor';
+ $this->logger = $logger;
+ }
+
+ public function getName() {
+ return 'Make Mail itinerary extractor executable';
+ }
+
+ public function run(IOutput $output) {
+ if (!is_file($this->file)) {
+ $this->logger->warning('itinerary file doesn\'t exist');
+ $output->info('itinerary file doesn\'t exist');
+ return;
+ }
+ if (is_executable($this->file)) {
+ $this->logger->debug('itinerary is already executable');
+ return;
+ }
+ try {
+ @chmod($this->file, 744);
+ } catch (Throwable $e) {
+ $this->logger->logException($e, [
+ 'message' => 'Can\'t make itinerary extractor executable',
+ ]);
+ $output->warning('Can\'t make itinerary extractor executable: ' . $e->getMessage());
+ return;
+ }
+ }
+
+}