From 8a73b6497f7375cb9d5a67d68576073c136dc14b Mon Sep 17 00:00:00 2001 From: Jesse Dowell Date: Fri, 16 Sep 2022 16:36:53 -0400 Subject: [PATCH] update README, fix default group channel handling, see TODOs for next work --- README.md | 7 ++----- src/mirthsync/apis.clj | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4211072..6571271 100644 --- a/README.md +++ b/README.md @@ -263,14 +263,11 @@ Requires [Leiningen](https://leiningen.org/) ## Todo -- Add the ability to selectively push or pull any channel, group, - script, etc (this is in progress) -- Add granular extraction of scripts into their own files and merge - back into XML for pushing +- Gracefully handle renames and deletions ## License -Copyright © 2017-2021 Saga IT LLC +Copyright © 2017-2022 Saga IT LLC Distributed under the Eclipse Public License either version 1.0 or any later version. diff --git a/src/mirthsync/apis.clj b/src/mirthsync/apis.clj index d552997..7dc288a 100644 --- a/src/mirthsync/apis.clj +++ b/src/mirthsync/apis.clj @@ -451,19 +451,24 @@ ;; ************** TODO - deal with the duplication/ugliness -(defmethod mi/deconstruct-node :channels [{:keys [disk-mode] :as app-conf} file-path el-loc] - (case (int disk-mode) - 1 (let [index-loc (mx/to-zip (slurp file-path))] - [[file-path (cdx/indent-str (cz/root (mx/add-update-child (cdzx/xml1-> index-loc :channels) el-loc)))]]) - 2 [[file-path (cdx/indent-str (cz/node el-loc))]] - (deconstruct-node - file-path - el-loc - (fn [el-loc] - (some (fn [[name script]] - (when-let [script-loc (script el-loc)] - [(name script-loc) script-loc])) - channel-deconstructors))))) +(defmethod mi/deconstruct-node :channels [{:keys [disk-mode] :as app-conf} ^String file-path el-loc] + ;; handle default-group channels + (let [effective-disk-mode (if (and (= 1 disk-mode) + (not (.endsWith file-path (str File/separator "index.xml")))) + 2 + disk-mode)] + (case (int effective-disk-mode) + 1 (let [index-loc (mx/to-zip (slurp file-path))] + [[file-path (cdx/indent-str (cz/root (mx/add-update-child (cdzx/xml1-> index-loc :channels) el-loc)))]]) + 2 [[file-path (cdx/indent-str (cz/node el-loc))]] + (deconstruct-node + file-path + el-loc + (fn [el-loc] + (some (fn [[name script]] + (when-let [script-loc (script el-loc)] + [(name script-loc) script-loc])) + channel-deconstructors)))))) (defmethod mi/deconstruct-node :code-templates [{:keys [disk-mode] :as app-conf} file-path el-loc] (case (int disk-mode)