Skip to content

Commit

Permalink
Close metadata properly
Browse files Browse the repository at this point in the history
  • Loading branch information
qpfiffer committed Oct 3, 2023
1 parent 0391aca commit 0131a7d
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/Filters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ function Filters.all_bumps_json(text, ctext)
end

for dont_care, line in pairs(all_bumps) do
local meta_data = Utils.check_for_bump(line)
local obj = {}

local is_nsfw = false
Expand All @@ -162,29 +161,32 @@ function Filters.all_bumps_json(text, ctext)
is_nsfw = cached_bump["is_nsfw"]
video = cached_bump["video"]
image = cached_bump["image"]
elseif meta_data then
local ctext = fuck_json.decode(meta_data:read("*all"))
bump_cache[line] = {text = "", is_nsfw = false, video = "", image = ""}
if ctext["nsfw"] then
is_nsfw = ctext["nsfw"]
bump_cache[line]["nsfw"] = is_nsfw
end
if ctext["text"] then
text = ctext["text"]
bump_cache[line]["text"] = text
end
if ctext["webm"] then
video = ctext["webm"]
bump_cache[line]["video"] = video
end
if ctext["image"] then
image = ctext["image"]
bump_cache[line]["image"] = image
elseif ctext["imageRepeat"] then
image = ctext["imageRepeat"]
bump_cache[line]["image"] = image
else
local meta_data = Utils.check_for_bump(line)
if meta_data then
local ctext = fuck_json.decode(meta_data:read("*all"))
bump_cache[line] = {text = "", is_nsfw = false, video = "", image = ""}
if ctext["nsfw"] then
is_nsfw = ctext["nsfw"]
bump_cache[line]["nsfw"] = is_nsfw
end
if ctext["text"] then
text = ctext["text"]
bump_cache[line]["text"] = text
end
if ctext["webm"] then
video = ctext["webm"]
bump_cache[line]["video"] = video
end
if ctext["image"] then
image = ctext["image"]
bump_cache[line]["image"] = image
elseif ctext["imageRepeat"] then
image = ctext["imageRepeat"]
bump_cache[line]["image"] = image
end
meta_data:close()
end
meta_data:close()
end

if not first then
Expand Down

0 comments on commit 0131a7d

Please sign in to comment.