Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit 86a5360

Browse files
committed
small tweaks to decompression code
1 parent 3465192 commit 86a5360

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Localizations/Neuron_X-enUS.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ L["Export"] = true
532532
L["Import or Export the current profile:"] = true
533533
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."
534534
L["ImportWarning"] = "Are you absolutely certain you wish to import this profile? The current profile will be overwritten."
535+
L["No data to import."] = true
535536
L["Decoding failed."] = true
536537
L["Decompression failed."] = true
537538
L["Data import Failed."] = true

Neuron.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,21 +693,30 @@ end
693693

694694

695695
function Neuron:SetSerializedAndCompressedProfile(input)
696+
--check if the input is empty
697+
if input == "" then
698+
Neuron:Print(L["No data to import."].." "..L["Aborting."])
699+
return
700+
end
701+
702+
--decode and check if decoding worked properly
696703
local decoded = LibDeflate:DecodeForPrint(input)
697704
if decoded == nil then
698705
Neuron:Print(L["Decoding failed."].." "..L["Aborting."])
699706
return
700707
end
701708

709+
--uncompress and check if uncompresion worked properly
702710
local uncompressed = LibDeflate:DecompressZlib(decoded)
703711
if uncompressed == nil then
704-
Neuron:Print(L["Decompression failed"].." "..L["Aborting."])
712+
Neuron:Print(L["Decompression failed."].." "..L["Aborting."])
705713
return
706714
end
707715

716+
--deserialize the data and return it back into a table format
708717
local result, newProfile = Neuron:Deserialize(uncompressed)
709718

710-
if result == true and newProfile then
719+
if result == true and newProfile then --if we successfully deserialize, load the new table and reload
711720
for k,v in pairs(newProfile) do
712721
if type(v) == "table" then
713722
Neuron.db.profile[k] = CopyTable(v)
@@ -717,6 +726,6 @@ function Neuron:SetSerializedAndCompressedProfile(input)
717726
end
718727
ReloadUI()
719728
else
720-
Neuron:Print(L["Data import Failed"].." "..L["Aborting."])
729+
Neuron:Print(L["Data import Failed."].." "..L["Aborting."])
721730
end
722731
end

0 commit comments

Comments
 (0)