Skip to content

Commit 42d04d6

Browse files
committed
Patch 2
1 parent c1b311d commit 42d04d6

File tree

3 files changed

+58
-47
lines changed

3 files changed

+58
-47
lines changed

lua/gpm/fs.lua

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ end
9898

9999
function IsDir( filePath, gamePath )
100100
if IsMounted( filePath, gamePath, true ) or file.IsDir( filePath, gamePath ) then return true end
101-
if SERVER then return false end
102101

103102
local _, folders = Find( filePath .. "*", gamePath )
104103
if folders == nil or #folders == 0 then return false end
@@ -225,53 +224,63 @@ end
225224

226225
local asyncSources = {
227226
{
228-
CanBeInstalled = asyncio ~= nil,
229-
Functions = {
230-
append = asyncio and asyncio.Append,
231-
write = asyncio and asyncio.Write,
232-
read = asyncio and asyncio.Read
233-
}
227+
Available = asyncio ~= nil,
228+
Get = function()
229+
return {
230+
append = asyncio.Append,
231+
write = asyncio.Write,
232+
read = asyncio.Read
233+
}
234+
end
234235
},
235236
{
236-
CanBeInstalled = file.AsyncAppen ~= nil,
237-
Functions = {
238-
append = file.AsyncAppen
239-
}
237+
Available = file.AsyncAppen ~= nil,
238+
Get = function()
239+
return {
240+
append = file.AsyncAppen
241+
}
242+
end
240243
},
241244
{
242-
CanBeInstalled = file.AsyncWrite ~= nil,
243-
Functions = {
244-
write = file.AsyncWrite
245-
}
245+
Available = file.AsyncWrite ~= nil,
246+
Get = function()
247+
return {
248+
write = file.AsyncWrite
249+
}
250+
end
246251
},
247252
{
248-
CanBeInstalled = file.AsyncRead ~= nil and gpm_fs_gmod_async:GetBool(),
249-
Functions = {
250-
read = file.AsyncRead
251-
}
253+
Available = file.AsyncRead ~= nil and gpm_fs_gmod_async:GetBool(),
254+
Get = function()
255+
return {
256+
read = file.AsyncRead
257+
}
258+
end
252259
},
253260
{
254-
CanBeInstalled = true,
255-
Functions = {
256-
append = function( fileName, content, func )
257-
local ok = pcall( Append, fileName, content, true )
258-
local state = ok and 0 or -1
259-
func( fileName, "DATA", state )
260-
return state
261-
end,
262-
write = function( fileName, content, func )
263-
local ok = pcall( Write, fileName, content, "wb", true )
264-
local state = ok and 0 or -1
265-
func( fileName, "DATA", state )
266-
return state
267-
end,
268-
read = function( fileName, gamePath, func )
269-
local ok, content = pcall( Read, fileName, gamePath )
270-
local state = ok and 0 or -1
271-
func( fileName, gamePath, state, content )
272-
return state
273-
end
274-
}
261+
Available = true,
262+
Get = function()
263+
return {
264+
append = function( fileName, content, func )
265+
local ok = pcall( Append, fileName, content, true )
266+
local state = ok and 0 or -1
267+
func( fileName, "DATA", state )
268+
return state
269+
end,
270+
write = function( fileName, content, func )
271+
local ok = pcall( Write, fileName, content, "wb", true )
272+
local state = ok and 0 or -1
273+
func( fileName, "DATA", state )
274+
return state
275+
end,
276+
read = function( fileName, gamePath, func )
277+
local ok, content = pcall( Read, fileName, gamePath )
278+
local state = ok and 0 or -1
279+
func( fileName, gamePath, state, content )
280+
return state
281+
end
282+
}
283+
end
275284
}
276285
}
277286

@@ -282,13 +291,15 @@ local async = {
282291
}
283292

284293
for _, source in ipairs( asyncSources ) do
285-
if not source.CanBeInstalled then continue end
294+
if not source.Available then continue end
295+
local functions = source.Get()
296+
286297
for funcName, func in pairs( async ) do
287298
if func ~= false then continue end
288-
289-
func = source.Functions[ funcName ]
290-
if not func then continue end
291-
async[ funcName ] = func
299+
func = functions[ funcName ]
300+
if func then
301+
async[ funcName ] = func
302+
end
292303
end
293304
end
294305

lua/gpm/import.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ do
171171
end
172172

173173
if not task then
174-
return promise.Reject( "Requested package doesn't exist." )
174+
return promise.Reject( "requested package doesn't exist." )
175175
end
176176
end
177177

lua/gpm/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Msg( [[
3232
module( "gpm", package.seeall )
3333

3434
StartTime = SysTime()
35-
VERSION = "1.52.1"
35+
VERSION = "1.52.2"
3636

3737
if not Colors then
3838
Realm = "unknown"

0 commit comments

Comments
 (0)