diff --git a/Localizations/Neuron_X-enUS.lua b/Localizations/Neuron_X-enUS.lua index 86fe0da..d697e16 100644 --- a/Localizations/Neuron_X-enUS.lua +++ b/Localizations/Neuron_X-enUS.lua @@ -532,6 +532,7 @@ L["Export"] = true L["Import or Export the current profile:"] = true L["ImportExport_Desc"] = "Copying the profile can be a time consuming experience. It may stall your game for multiple seconds. WARNING: It will overwrite the current profile." L["ImportWarning"] = "Are you absolutely certain you wish to import this profile? The current profile will be overwritten." +L["No data to import."] = true L["Decoding failed."] = true L["Decompression failed."] = true L["Data import Failed."] = true diff --git a/Neuron.lua b/Neuron.lua index d9ac87d..9dc1d45 100644 --- a/Neuron.lua +++ b/Neuron.lua @@ -693,21 +693,30 @@ end function Neuron:SetSerializedAndCompressedProfile(input) + --check if the input is empty + if input == "" then + Neuron:Print(L["No data to import."].." "..L["Aborting."]) + return + end + + --decode and check if decoding worked properly local decoded = LibDeflate:DecodeForPrint(input) if decoded == nil then Neuron:Print(L["Decoding failed."].." "..L["Aborting."]) return end + --uncompress and check if uncompresion worked properly local uncompressed = LibDeflate:DecompressZlib(decoded) if uncompressed == nil then - Neuron:Print(L["Decompression failed"].." "..L["Aborting."]) + Neuron:Print(L["Decompression failed."].." "..L["Aborting."]) return end + --deserialize the data and return it back into a table format local result, newProfile = Neuron:Deserialize(uncompressed) - if result == true and newProfile then + if result == true and newProfile then --if we successfully deserialize, load the new table and reload for k,v in pairs(newProfile) do if type(v) == "table" then Neuron.db.profile[k] = CopyTable(v) @@ -717,6 +726,6 @@ function Neuron:SetSerializedAndCompressedProfile(input) end ReloadUI() else - Neuron:Print(L["Data import Failed"].." "..L["Aborting."]) + Neuron:Print(L["Data import Failed."].." "..L["Aborting."]) end end \ No newline at end of file