mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Enhance ServeSession to fetch git metadata before initial patch computation
- Updated the `ServeSession:start` function to retrieve git metadata from the API before computing the initial patch. This change ensures that the server information includes relevant git details, improving synchronization accuracy. - Disabled the polling feature in `App:startSyncReminderPolling` due to performance concerns, as it was deemed unnecessary. - Adjusted the API service to set `git_metadata` to `None` instead of computing it, streamlining the response handling. These changes aim to optimize the synchronization process and reduce unnecessary API calls.
This commit is contained in:
parent
8b4573b578
commit
491d433a6b
3 changed files with 55 additions and 64 deletions
|
|
@ -542,6 +542,10 @@ function App:checkSyncReminder()
|
|||
end
|
||||
|
||||
function App:startSyncReminderPolling()
|
||||
-- Feature disabled: polling GET /api/rojo every 30s is expensive and
|
||||
-- the setting was hidden behind showNotifications anyway.
|
||||
do return end
|
||||
|
||||
if
|
||||
self.syncReminderPollingThread ~= nil
|
||||
or Settings:get("syncReminderMode") == "None"
|
||||
|
|
|
|||
|
|
@ -350,48 +350,57 @@ function ServeSession:start()
|
|||
|
||||
self.__serverInfo = serverInfo
|
||||
|
||||
local computePatchClock = os.clock()
|
||||
Log.debug("[TIMING] __computeInitialPatch() starting")
|
||||
return self:__computeInitialPatch(serverInfo):andThen(function(catchUpPatch)
|
||||
Log.debug(
|
||||
"[TIMING] __computeInitialPatch() completed ({} ms)",
|
||||
string.format("%.1f", (os.clock() - computePatchClock) * 1000)
|
||||
)
|
||||
self:setLoadingText("Starting sync loop...")
|
||||
|
||||
local wsClock = os.clock()
|
||||
Log.debug("[TIMING] connectWebSocket() starting")
|
||||
-- Connect WebSocket BEFORE showing confirmation so changes
|
||||
-- during confirmation can be merged into the patch
|
||||
-- Note: connectWebSocket returns a Promise that only resolves when
|
||||
-- the connection closes, so we don't chain .andThen() on it
|
||||
self.__apiContext
|
||||
:connectWebSocket({
|
||||
["messages"] = function(messagesPacket)
|
||||
self:__onWebSocketMessage(messagesPacket)
|
||||
end,
|
||||
})
|
||||
:catch(function(err)
|
||||
if self.__status ~= Status.Disconnected then
|
||||
self:__stopInternal(err)
|
||||
end
|
||||
end)
|
||||
Log.debug(
|
||||
"[TIMING] connectWebSocket() initiated ({} ms)",
|
||||
string.format("%.1f", (os.clock() - wsClock) * 1000)
|
||||
)
|
||||
|
||||
local confirmClock = os.clock()
|
||||
Log.debug("[TIMING] __confirmAndApplyInitialPatch() starting")
|
||||
-- Now show confirmation and wait for user decision
|
||||
return self:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo):andThen(function(...)
|
||||
Log.debug(
|
||||
"[TIMING] __confirmAndApplyInitialPatch() completed ({} ms)",
|
||||
string.format("%.1f", (os.clock() - confirmClock) * 1000)
|
||||
)
|
||||
return ...
|
||||
self:setLoadingText("Fetching git metadata...")
|
||||
return self.__apiContext
|
||||
:getGitMetadata()
|
||||
:andThen(function(gitMeta)
|
||||
serverInfo.gitMetadata = gitMeta
|
||||
end)
|
||||
:catch(function() end)
|
||||
:andThen(function()
|
||||
local computePatchClock = os.clock()
|
||||
Log.debug("[TIMING] __computeInitialPatch() starting")
|
||||
return self:__computeInitialPatch(serverInfo):andThen(function(catchUpPatch)
|
||||
Log.debug(
|
||||
"[TIMING] __computeInitialPatch() completed ({} ms)",
|
||||
string.format("%.1f", (os.clock() - computePatchClock) * 1000)
|
||||
)
|
||||
self:setLoadingText("Starting sync loop...")
|
||||
|
||||
local wsClock = os.clock()
|
||||
Log.debug("[TIMING] connectWebSocket() starting")
|
||||
-- Connect WebSocket BEFORE showing confirmation so changes
|
||||
-- during confirmation can be merged into the patch
|
||||
-- Note: connectWebSocket returns a Promise that only resolves when
|
||||
-- the connection closes, so we don't chain .andThen() on it
|
||||
self.__apiContext
|
||||
:connectWebSocket({
|
||||
["messages"] = function(messagesPacket)
|
||||
self:__onWebSocketMessage(messagesPacket)
|
||||
end,
|
||||
})
|
||||
:catch(function(err)
|
||||
if self.__status ~= Status.Disconnected then
|
||||
self:__stopInternal(err)
|
||||
end
|
||||
end)
|
||||
Log.debug(
|
||||
"[TIMING] connectWebSocket() initiated ({} ms)",
|
||||
string.format("%.1f", (os.clock() - wsClock) * 1000)
|
||||
)
|
||||
|
||||
local confirmClock = os.clock()
|
||||
Log.debug("[TIMING] __confirmAndApplyInitialPatch() starting")
|
||||
-- Now show confirmation and wait for user decision
|
||||
return self:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo):andThen(function(...)
|
||||
Log.debug(
|
||||
"[TIMING] __confirmAndApplyInitialPatch() completed ({} ms)",
|
||||
string.format("%.1f", (os.clock() - confirmClock) * 1000)
|
||||
)
|
||||
return ...
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
:andThen(function()
|
||||
Log.debug(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue