From 0e762775014cac433823261f8f5f308b229b9e81 Mon Sep 17 00:00:00 2001 From: ACTom Date: Tue, 29 Dec 2020 01:18:28 +0800 Subject: [PATCH] Add support for NC 21 Signed-off-by: ACTom --- Makefile | 2 +- appinfo/info.xml | 6 +++--- lib/Migration/InstallStep.php | 15 +++++++++------ lib/Migration/UninstallStep.php | 20 ++++++++++++-------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index f5e7850..0d70769 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ source_dir=$(build_dir)/source sign_dir=$(build_dir)/sign package_name=$(app_name) cert_dir=$(CURDIR)/../../key -version+=0.0.23 +version+=0.0.24 all: appstore diff --git a/appinfo/info.xml b/appinfo/info.xml index 128e5cf..18047e9 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,20 +5,20 @@ Mind Map A Mind map editor - 0.0.23 + 0.0.24 agpl Jingtao Yan Files_MindMap files office + https://github.com/ACTom/files_mindmap https://github.com/ACTom/files_mindmap/issues https://github.com/ACTom/files_mindmap.git - https://github.com/ACTom/files_mindmap https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/1.png https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/2.png https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/3.png - + diff --git a/lib/Migration/InstallStep.php b/lib/Migration/InstallStep.php index 2ff789a..ca20356 100644 --- a/lib/Migration/InstallStep.php +++ b/lib/Migration/InstallStep.php @@ -31,14 +31,17 @@ public function getName() { /** * @param IOutput $output */ - public function run(IOutput $output) { + public function run(IOutput $output) { $currentVersion = implode('.', \OC_Util::getVersion()); - $this->logger->info("Copy mindmap icon to core/img directory.", ["app" => "files_mindmap"]); - $appImagePath = __DIR__ . '/../../img/mindmap.svg'; - $coreImagePath = \OC::$SERVERROOT . '/core/img/filetypes/mindmap.svg'; - if (!file_exists($coreImagePath) || md5_file($coreImagePath) !== md5_file($appImagePath)) { - copy($appImagePath, $coreImagePath); + if (version_compare($currentVersion, '21.0.0.11', '<')) { + /* Since 21.0.0 beta4, NC has mindmap's mimetype icon */ + $this->logger->info("Copy mindmap icon to core/img directory.", ["app" => "files_mindmap"]); + $appImagePath = __DIR__ . '/../../img/mindmap.svg'; + $coreImagePath = \OC::$SERVERROOT . '/core/img/filetypes/mindmap.svg'; + if (!file_exists($coreImagePath) || md5_file($coreImagePath) !== md5_file($appImagePath)) { + copy($appImagePath, $coreImagePath); + } } if (version_compare($currentVersion, '19.0.0.4', '<')) { diff --git a/lib/Migration/UninstallStep.php b/lib/Migration/UninstallStep.php index 1fa3e66..3e679d0 100644 --- a/lib/Migration/UninstallStep.php +++ b/lib/Migration/UninstallStep.php @@ -30,14 +30,18 @@ public function getName() { * @param IOutput $output */ public function run(IOutput $output) { - $configDir = \OC::$configDir; - $mimetypealiasesFile = $configDir . 'mimetypealiases.json'; - $mimetypemappingFile = $configDir . 'mimetypemapping.json'; - - $this->removeFromFile($mimetypealiasesFile, ['application/km' => 'mindmap', 'application/x-freemind' => 'mindmap', 'application/vnd.xmind.workbook' => 'mindmap']); - $this->removeFromFile($mimetypemappingFile, ['km' => ['application/km'], 'mm' => ['application/x-freemind'], 'xmind' => ['application/vnd.xmind.workbook']]); - $this->logger->info("Remove .km,.mm,.xmind from mimetype list.", ["app" => "files_mindmap"]); - $this->updateJS->run(new StringInput(''), new ConsoleOutput()); + $currentVersion = implode('.', \OC_Util::getVersion()); + if (version_compare($currentVersion, '19.0.0.4', '<')) { + /* Since 19.0.0.beta3, NC has mindmap's mimetype */ + $configDir = \OC::$configDir; + $mimetypealiasesFile = $configDir . 'mimetypealiases.json'; + $mimetypemappingFile = $configDir . 'mimetypemapping.json'; + + $this->removeFromFile($mimetypealiasesFile, ['application/km' => 'mindmap', 'application/x-freemind' => 'mindmap', 'application/vnd.xmind.workbook' => 'mindmap']); + $this->removeFromFile($mimetypemappingFile, ['km' => ['application/km'], 'mm' => ['application/x-freemind'], 'xmind' => ['application/vnd.xmind.workbook']]); + $this->logger->info("Remove .km,.mm,.xmind from mimetype list.", ["app" => "files_mindmap"]); + $this->updateJS->run(new StringInput(''), new ConsoleOutput()); + } } private function removeFromFile(string $filename, array $data) {