Skip to content

Commit

Permalink
fix: reinitialize the server if the plugin was installed with the ser…
Browse files Browse the repository at this point in the history
…ver already present
  • Loading branch information
vyfor committed Jan 23, 2025
1 parent 0530d00 commit ed60ef6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lua/cord/server/update/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ M.fetch = async.wrap(function()
.. '-'
.. (os_info.name == 'windows' and 'cord.exe' or 'cord')

local cord = require 'cord.server'
local function initialize()
async.run(function()
process
Expand Down Expand Up @@ -213,7 +212,7 @@ M.fetch = async.wrap(function()
async.run(function()
server.is_updating = false
require('cord.core.uv.fs').chmod(executable_path, '755'):await()
cord:initialize()
server:initialize()
end)
end, function(err)
server.is_updating = false
Expand All @@ -222,19 +221,19 @@ M.fetch = async.wrap(function()
end)
end

if cord.manager then cord.manager:cleanup() end
if not cord.tx then return initialize() end
if not cord.client then return initialize() end
if cord.client:is_closing() then return initialize() end
if server.manager then server.manager:cleanup() end
if not server.tx then return initialize() end
if not server.client then return initialize() end
if server.client:is_closing() then return initialize() end

if cord.client.on_close then cord.client.on_close() end
if server.client.on_close then server.client.on_close() end

cord.client.on_close = function()
cord.client.on_close = nil
server.client.on_close = function()
server.client.on_close = nil
initialize()
end

cord.tx:shutdown()
server.tx:shutdown()
end)

async.run(function()
Expand All @@ -245,6 +244,8 @@ M.fetch = async.wrap(function()
if latest == current then
server.is_updating = false
logger.info('Already on latest server version ' .. latest)

if not server.client or server.client:is_closing() then server:initialize() end
else
fetch_executable(latest)
end
Expand Down

0 comments on commit ed60ef6

Please sign in to comment.