@@ -281,21 +281,78 @@ function UUF:FrameIsValid(frameToAnchor, frameName)
281281end
282282
283283function UUF :FixDatabaseIssues ()
284- local function FixTable (defaultTable , userTable )
285- for k , v in pairs (defaultTable ) do
284+ local variablesAdded = {}
285+ local variablesRemoved = {}
286+
287+ local function Record (list , path )
288+ list [# list + 1 ] = path
289+ end
290+
291+ local function IsIgnoredPath (path )
292+ return path :match (" ^profileKeys" ) or path :match (" ^global" )
293+ end
294+
295+ local function Reconcile (defaults , user , path )
296+ path = path or " "
297+
298+ for k in pairs (user ) do
299+ if defaults [k ] == nil then
300+ local fullPath = path .. k
301+ if not IsIgnoredPath (fullPath ) then
302+ Record (variablesRemoved , fullPath )
303+ end
304+ user [k ] = nil
305+ end
306+ end
307+
308+ for k , v in pairs (defaults ) do
309+ local currentPath = path .. k
310+
286311 if type (v ) == " table" then
287- if type (userTable [k ]) ~= " table" then
288- userTable [k ] = UUF :CopyTable (v )
312+ if type (user [k ]) ~= " table" then
313+ user [k ] = UUF :CopyTable (v )
314+ if not IsIgnoredPath (currentPath ) then
315+ Record (variablesAdded , currentPath )
316+ end
289317 else
290- FixTable (v , userTable [k ])
318+ Reconcile (v , user [k ], currentPath .. " . " )
291319 end
292320 else
293- if userTable [k ] == nil then
294- userTable [k ] = v
321+ if user [k ] == nil then
322+ user [k ] = v
323+ if not IsIgnoredPath (currentPath ) then
324+ Record (variablesAdded , currentPath )
325+ end
295326 end
296327 end
297328 end
298329 end
299- FixTable (UUF .Defaults , UnhaltedUFDB )
300- UUF :Print (" Database issues have been fixed. Please review your settings to ensure everything is correct." )
330+
331+ local profileName = UUF .db :GetCurrentProfile ()
332+ local profileDB = UnhaltedUFDB .profiles [profileName ]
333+ if not profileDB then
334+ UUF :Print (" Database Reconcile Aborted, Profile '" .. profileName .. " ' not found." )
335+ return
336+ end
337+ Reconcile (UUF .Defaults .profile , profileDB )
338+ UUF :Print (" Database Reconcile Completed For: " .. profileName )
339+ if # variablesRemoved > 1 then
340+ UUF :Print (" Removed - " .. # variablesRemoved .. " :" )
341+ for _ , k in ipairs (variablesRemoved ) do
342+ if k ~= " profile" and k ~= " global" then
343+ UUF :Print (" • " .. k )
344+ end
345+ end
346+ else
347+ UUF :Print (" Nothing To Remove!" )
348+ end
349+
350+ if # variablesAdded > 0 then
351+ UUF :Print (" Added - " .. # variablesAdded .. " :" )
352+ for _ , k in ipairs (variablesAdded ) do
353+ UUF :Print (" • " .. k )
354+ end
355+ else
356+ UUF :Print (" Nothing To Add!" )
357+ end
301358end
0 commit comments