Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lua/advdupe2/cl_file.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function AdvDupe2.ReceiveFile(data, autoSave)
AdvDupe2.RemoveProgressBar()
if not data then
AdvDupe2.Notify("File was not saved!",NOTIFY_ERROR,5)
AdvDupe2.Notify("File was not saved! (No data)",NOTIFY_ERROR,5)
return
end
local path
Expand All @@ -18,7 +18,7 @@ function AdvDupe2.ReceiveFile(data, autoSave)
path = AdvDupe2.SanitizeFilename(path)
local dupefile = file.Open(path, "wb", "DATA")
if not dupefile then
AdvDupe2.Notify("File was not saved!",NOTIFY_ERROR,5)
AdvDupe2.Notify("File was not saved! (Could not open file for writing)",NOTIFY_ERROR,5)
return
end
dupefile:Write(data)
Expand All @@ -32,7 +32,7 @@ function AdvDupe2.ReceiveFile(data, autoSave)
if not readFile then AdvDupe2.Notify("File could not be read", NOTIFY_ERROR) return end
local readData = readFile:Read(readFile:Size())
readFile:Close()
local success,dupe,info,moreinfo = AdvDupe2.Decode(readData)
local success, dupe, _info, _moreinfo = AdvDupe2.Decode(readData)
if(success)then
AdvDupe2.Notify("DEBUG CHECK: File successfully opens. No EOF errors.")
else
Expand Down Expand Up @@ -60,7 +60,7 @@ function AdvDupe2.ReceiveFile(data, autoSave)
AdvDupe2.FileBrowser.Browser.pnlCanvas.ActionNode:AddFile(filename)
AdvDupe2.FileBrowser.Browser.pnlCanvas:Sort(AdvDupe2.FileBrowser.Browser.pnlCanvas.ActionNode)
end
if(!errored)then
if not errored then
AdvDupe2.Notify("File successfully saved!",NOTIFY_GENERIC, 5)
end
end
Expand Down
3 changes: 1 addition & 2 deletions lua/advdupe2/file_browser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
local History = {}
local Narrow = {}

local switch = true

Check warning on line 14 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: switch
local count = 0

local function AddHistory(txt)
Expand Down Expand Up @@ -257,6 +257,7 @@
end

function AdvDupe2.GetFilename(path, overwrite)
path = AdvDupe2.SanitizeFilename(path)
if not overwrite and file.Exists(path .. ".txt", "DATA") then
for i = 1, AdvDupe2.FileRenameTryLimit do
local p = string.format("%s_%03d.txt", path, i)
Expand All @@ -273,7 +274,7 @@
local path, area = GetNodePath(node)
if (area == 0) then
path = AdvDupe2.DataFolder .. "/" .. path .. "/"
elseif (area == 1) then

Check warning on line 277 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Empty block"

Empty elseif statement

else
path = "adv_duplicator/" .. path .. "/"
Expand Down Expand Up @@ -339,8 +340,6 @@
return
end
local base = AdvDupe2.DataFolder
local ParentNode

local node2 = node.Control.ActionNode
local path, area = GetNodePath(node2)
local path2, area2 = GetNodePath(node)
Expand Down Expand Up @@ -519,17 +518,17 @@
end)
Menu:AddOption("Delete", function()
parent.Submit:SetMaterial("icon16/bin_empty.png")
parent.Submit:SetTooltip("Delete File")

Check warning on line 521 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
parent.FileName:SetVisible(false)
parent.Desc:SetVisible(false)
if (#node.Label:GetText() > 22) then
parent.Info:SetText(
'Are you sure that you want to delete \nthe FILE, "' ..

Check warning on line 526 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
node.Label:GetText() .. '" \nfrom your CLIENT?')
else
parent.Info:SetText(
'Are you sure that you want to delete \nthe FILE, "' ..
node.Label:GetText() .. '" from your CLIENT?')

Check warning on line 531 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'
end
parent.Info:SizeToContents()
parent.Info:SetVisible(true)
Expand All @@ -537,7 +536,7 @@
parent.Submit.DoClick = function()
local path, area = GetNodePath(node)
if (area == 1) then
path = "-Public-/" .. path

Check warning on line 539 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'
end
if (area == 2) then
path = "adv_duplicator/" .. path .. ".txt"
Expand Down Expand Up @@ -643,10 +642,10 @@
AddHistory(parent.FileName:GetValue())
parent.FileName:SetVisible(false)
parent.Submit:SetMaterial("icon16/arrow_undo.png")
parent.Submit:SetTooltip("Return to Browser")

Check warning on line 645 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
parent.Info:SetVisible(true)
parent.Info:SetText(#parent.Search.pnlCanvas.Files ..
' files found searching for, "' ..

Check warning on line 648 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
parent.FileName:GetValue() .. '"')
parent.Info:SizeToContents()
parent.Submit.DoClick = function()
Expand All @@ -663,7 +662,7 @@
if (node.Label:GetText()[1] ~= "-") then
Menu:AddOption("Delete", function()
parent.Submit:SetMaterial("icon16/bin_empty.png")
parent.Submit:SetTooltip("Delete Folder")

Check warning on line 665 in lua/advdupe2/file_browser.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
parent.FileName:SetVisible(false)
parent.Desc:SetVisible(false)
if (#node.Label:GetText() > 22) then
Expand Down
12 changes: 4 additions & 8 deletions lua/advdupe2/sh_codec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
AddCSLuaFile( "sh_codec_legacy.lua" )

local pairs = pairs
local type = type
local error = error
local Vector = Vector
local Angle = Angle
local format = string.format
local char = string.char
local byte = string.byte
local sub = string.sub
local gsub = string.gsub
local find = string.find
local gmatch = string.gmatch
local match = string.match
local concat = table.concat
local compress = util.Compress
local decompress = util.Decompress
Expand All @@ -49,7 +42,10 @@
end

function AdvDupe2.SanitizeFilename(filename)
return string.gsub(string.gsub(filename, "[\":]", "_"), "%s+", " ")
filename = string.gsub( filename, "[\":]", "_" )
filename = string.gsub( filename, "%s+", " " )
filename = string.gsub( filename, "%s*([\\/%.])%s*", "%1" )
return filename
end

local function makeInfo(tbl)
Expand Down Expand Up @@ -536,7 +532,7 @@
if not readFile then print("File could not be read or found! ("..readFileName..")") return end
local readData = readFile:Read(readFile:Size())
readFile:Close()
local ok, tbl = AdvDupe2.Decode(readData)

Check warning on line 535 in lua/advdupe2/sh_codec.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: ok
local writeFile = file.Open(writeFileName, "wb", "DATA")
if not writeFile then print("File could not be written! ("..writeFileName..")") return end
writeFile:Write(util.TableToJSON(tbl))
Expand Down
Loading