add optional param to force overwrite imported profile

This commit is contained in:
Nnoggie
2024-06-25 17:16:45 +02:00
committed by andrew6180
parent dd3a4edb98
commit fa60359e2c
+9 -6
View File
@@ -1742,8 +1742,9 @@ end
---@param newProfileName string
---@param bImportAutoRunCode boolean
---@param bIsFromImportPrompt boolean
---@param overwriteProfile boolean --if the profile already exists, overwrite it
---@return boolean
function Details:ImportProfile (profileString, newProfileName, bImportAutoRunCode, bIsFromImportPrompt)
function Details:ImportProfile (profileString, newProfileName, bImportAutoRunCode, bIsFromImportPrompt, overwriteProfile)
if (not newProfileName or type(newProfileName) ~= "string" or string.len(newProfileName) < 2) then
Details:Msg("invalid profile name or profile name is too short.") --localize-me
return false
@@ -1757,11 +1758,13 @@ function Details:ImportProfile (profileString, newProfileName, bImportAutoRunCod
local profileObject = Details:GetProfile (newProfileName, false)
local nameWasDuplicate = false
while(profileObject) do
newProfileName = newProfileName .. '2';
profileObject = Details:GetProfile(newProfileName, false)
nameWasDuplicate = true
end
if not overwriteProfile then
while(profileObject) do
newProfileName = newProfileName .. '2';
profileObject = Details:GetProfile(newProfileName, false)
nameWasDuplicate = true
end
end
if (not profileObject) then
--profile doesn't exists, create new
profileObject = Details:CreateProfile (newProfileName)