|
68 | 68 |
|
69 | 69 | (defn- conflict-append |
70 | 70 | [{:keys [path in]}] |
71 | | - {:write {path {:string (str (System/lineSeparator) (stream->string in)), :append true}}}) |
| 71 | + {:write {path {:string (str "\n" (stream->string in)), :append true}}}) |
72 | 72 |
|
73 | 73 | (defn- conflict-append-dedupe |
74 | | - [{:keys [lib path in ^File existing state] :as _params}] |
| 74 | + [{:keys [path in ^File existing state] :as _params}] |
75 | 75 | (let [existing-content (slurp existing) |
76 | 76 | existing-lower (str/lower-case existing-content) |
77 | 77 | new-content (stream->string in) |
78 | 78 | new-content-lower (str/lower-case new-content) |
79 | 79 | seen (or (get-in state [:append-dedupe path]) #{existing-lower})] |
80 | | - (println "\nconflict-append-dedupe" path lib) |
81 | | - (println "state:" state) |
82 | | - (println "seen:" seen) |
83 | | - (println "existing:" existing-lower) |
84 | | - (println "new content:" new-content-lower) |
85 | | - (println "contains:" (contains? seen new-content-lower)) |
86 | | - (println) |
87 | 80 | (if (contains? seen new-content-lower) |
88 | 81 | ;; already seen |
89 | 82 | {:state (assoc-in state [:append-dedupe path] seen)} |
90 | 83 | ;; record and append |
91 | 84 | {:state (assoc-in state [:append-dedupe path] (conj seen new-content)) |
92 | | - :write {path {:string (str (System/lineSeparator) new-content), :append true}}}))) |
| 85 | + :write {path {:string (str "\n" new-content), :append true}}}))) |
93 | 86 |
|
94 | 87 | (defn conflict-data-readers |
95 | 88 | [{:keys [path in ^File existing]}] |
|
116 | 109 | [^FileTime last-modified-time buffer out-dir path write-spec] |
117 | 110 | (let [{:keys [string stream append] :or {append false}} write-spec |
118 | 111 | out-file (jio/file out-dir path)] |
119 | | - (when (and append string) |
120 | | - (prn "APPEND" path string)) |
121 | 112 | (if string |
122 | 113 | (spit out-file string :append ^boolean append) |
123 | 114 | (copy-stream! ^InputStream stream (BufferedOutputStream. (FileOutputStream. out-file ^boolean append)) buffer)) |
124 | 115 | (Files/setLastModifiedTime (.toPath out-file) last-modified-time))) |
125 | 116 |
|
126 | 117 | (defn- handle-conflict |
127 | | - [handlers last-modified-time buffer out-dir {:keys [lib state path] :as handler-params}] |
| 118 | + [handlers last-modified-time buffer out-dir {:keys [state path] :as handler-params}] |
128 | 119 | (let [use-handler (loop [[[re handler] & hs] (dissoc handlers :default)] |
129 | 120 | (if re |
130 | 121 | (if (re-matches re path) |
131 | 122 | handler |
132 | 123 | (recur hs)) |
133 | 124 | (:default handlers)))] |
134 | | - (when (= "META-INF/LICENSE.txt" path) |
135 | | - (println "handle-conflict" (.getPath ^File out-dir) path lib (.getName (class use-handler)))) |
136 | 125 | (if use-handler |
137 | 126 | (let [{new-state :state, write :write} (use-handler handler-params)] |
138 | 127 | (when write |
|
156 | 145 | Returns possibly updated state for further exploding." |
157 | 146 | [^InputStream is ^String path dir? ^FileTime last-modified-time |
158 | 147 | ^File out-file lib {:keys [out-dir buffer exclude handlers] :as context} state] |
159 | | - (when (= path "META-INF\\LICENSE.txt") |
160 | | - (println "in explode1" |
161 | | - (exclude-from-uber? exclude path) |
162 | | - dir? |
163 | | - (.exists out-file))) |
164 | 148 | (cond |
165 | 149 | ;; excluded or directory - do nothing |
166 | 150 | (or (exclude-from-uber? exclude path) dir?) |
|
217 | 201 | (let [path (.toString (.relativize source-path (.toPath f))) |
218 | 202 | source-time (FileTime/fromMillis (.lastModified f)) |
219 | 203 | out-file (jio/file out-dir path)] |
220 | | - (when (str/includes? path "LICENSE") |
221 | | - (println "explode1 path" path source-path)) |
222 | 204 | (explode1 is path (.isDirectory f) source-time out-file lib context the-state)) |
223 | 205 | (finally |
224 | 206 | (when is (.close ^InputStream is))))] |
|
0 commit comments