Skip to content

Commit

Permalink
fix creation of first page if there is none
Browse files Browse the repository at this point in the history
  • Loading branch information
rkusa committed Aug 16, 2023
1 parent ac5a15b commit b1e9ecf
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions Scripts/Hooks/scratchpad-hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,42 +445,6 @@ local function loadScratchpad()
}
saveConfiguration()
end

-- scan scratchpad dir for pages
for name in lfs.dir(dirPath) do
local path = dirPath .. name
if lfs.attributes(path, "mode") == "file" then
if name:sub(-4) ~= ".txt" then
log("Ignoring file " .. name .. ", because of it doesn't seem to be a text file (.txt)")
elseif lfs.attributes(path, "size") > 1024 * 1024 then
log("Ignoring file " .. name .. ", because of its file size of more than 1MB")
else
log("found page " .. path)
table.insert(
pages,
{
name = name:sub(1, -5),
path = path
}
)
pagesCount = pagesCount + 1
end
end
end

-- there are no pages yet, create one
if pagesCount == 0 then
path = dirPath .. [[0000.txt]]
log("creating page " .. path)
table.insert(
pages,
{
name = "0000",
path = path
}
)
pagesCount = pagesCount + 1
end
end

local function saveConfiguration()
Expand Down Expand Up @@ -849,7 +813,6 @@ local function loadScratchpad()
local extensionsPath = lfs.writedir() .. [[Scripts\Scratchpad\Extensions\]]
for name in lfs.dir(extensionsPath) do
local path = extensionsPath .. name
log(path)
if lfs.attributes(path, "mode") == "file" then
if name:sub(-4) ~= ".lua" then
log("Ignoring file " .. name .. ", because of it doesn't seem to be an extension (.lua)")
Expand Down

0 comments on commit b1e9ecf

Please sign in to comment.