From b5cdd961967ea5f4948f223b3e734264794be3f9 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 17 Dec 2021 15:27:06 -0700 Subject: [PATCH] don't add duplicates to sources.tsv --- .../src/hollywoo_flixel/AssetMacros.kiss | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/hollywoo-flixel/src/hollywoo_flixel/AssetMacros.kiss b/projects/hollywoo-flixel/src/hollywoo_flixel/AssetMacros.kiss index e91b1fd9..100dd6ad 100644 --- a/projects/hollywoo-flixel/src/hollywoo_flixel/AssetMacros.kiss +++ b/projects/hollywoo-flixel/src/hollywoo_flixel/AssetMacros.kiss @@ -3,11 +3,15 @@ (defMacroFunction appendToSources [query resultNumber apiName author apiQuery] (unless (FileSystem.exists ASSET_SOURCES_FILE) (File.saveContent ASSET_SOURCES_FILE "")) - (File.saveContent - ASSET_SOURCES_FILE - (+ - (File.getContent ASSET_SOURCES_FILE) - "${query}\t${resultNumber}\t${apiName}\t${author}\t${apiQuery}\n"))) + (let [newLine "${query}\t${resultNumber}\t${apiName}\t${author}\t${apiQuery}\n" + existingSources (File.getContent ASSET_SOURCES_FILE)] + (unless !(= -1 (existingSources.indexOf newLine)) + (File.saveContent + ASSET_SOURCES_FILE + (+ + existingSources + (if (StringTools.endsWith existingSources "\n") "" "\n") + newLine))))) (defMacroFunction downloadToImages [query resultNumber apiName url] (let [ext