From e75133f8995c2c6915b4cb5da4b74a7db74d82c0 Mon Sep 17 00:00:00 2001 From: Tiffany Bennett Date: Tue, 28 Jun 2022 19:50:49 -0700 Subject: [PATCH] Only run migration when needed (fixes #64) --- src/TagManager.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/TagManager.lua b/src/TagManager.lua index a10abe7..71a1950 100644 --- a/src/TagManager.lua +++ b/src/TagManager.lua @@ -61,6 +61,20 @@ local function genColor(name: string): Color3 return Color3.fromHSV(h, s, v) end +local function needsMigration(folder: Folder): boolean + if not folder then + return false + end + + for _, child in folder:GetChildren() do + if child:IsA("Folder") then + return true + end + end + + return false +end + function TagManager.new(store) local self = setmetatable({ store = store, @@ -76,7 +90,7 @@ function TagManager.new(store) TagManager._global = self -- Migration path to new attribute based format. - if self._defaultTagsFolder then + if needsMigration(self._defaultTagsFolder) then ChangeHistory:SetWaypoint("Migrating tags folder") local migrateCount = 0