mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Prevent syncing while a sync is already in progress.
I'm fairly confident that there will be zero cases where the plugin gets into a bad state where you can't sync. This change also prefixes most of Rojo's messages with `Rojo:` to make them easier to identify. Fixes #61.
This commit is contained in:
parent
8c482f75dd
commit
c2cfcc7a2c
2 changed files with 22 additions and 9 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
* Rojo now throws an error if no project file is found. ([#63](https://github.com/LPGhatguy/rojo/issues/63))
|
* Rojo now throws an error if no project file is found. ([#63](https://github.com/LPGhatguy/rojo/issues/63))
|
||||||
|
* Fixed multiple sync operations occuring at the same time. ([#61](https://github.com/LPGhatguy/rojo/issues/61))
|
||||||
|
|
||||||
## 0.4.4 (April 7, 2018)
|
## 0.4.4 (April 7, 2018)
|
||||||
* Fix small regression introduced in 0.4.3
|
* Fix small regression introduced in 0.4.3
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ function Plugin.new()
|
||||||
_reconciler = Reconciler.new(),
|
_reconciler = Reconciler.new(),
|
||||||
_api = nil,
|
_api = nil,
|
||||||
_polling = false,
|
_polling = false,
|
||||||
|
_syncInProgress = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
setmetatable(self, Plugin)
|
setmetatable(self, Plugin)
|
||||||
|
|
@ -62,11 +63,12 @@ end
|
||||||
restarted.
|
restarted.
|
||||||
]]
|
]]
|
||||||
function Plugin:restart()
|
function Plugin:restart()
|
||||||
warn("The server has changed since the last request, reloading plugin...")
|
warn("Rojo: The server has changed since the last request, reloading plugin...")
|
||||||
|
|
||||||
self._reconciler:clear()
|
self._reconciler:clear()
|
||||||
self._api = nil
|
self._api = nil
|
||||||
self._polling = false
|
self._polling = false
|
||||||
|
self._syncInProgress = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function Plugin:api()
|
function Plugin:api()
|
||||||
|
|
@ -82,7 +84,7 @@ function Plugin:api()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Plugin:connect()
|
function Plugin:connect()
|
||||||
print("Testing connection...")
|
print("Rojo: Testing connection...")
|
||||||
|
|
||||||
return self:api()
|
return self:api()
|
||||||
:andThen(function(api)
|
:andThen(function(api)
|
||||||
|
|
@ -92,9 +94,9 @@ function Plugin:connect()
|
||||||
return Promise.reject(info)
|
return Promise.reject(info)
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Server found!")
|
print("Rojo: Server found!")
|
||||||
print("Protocol version:", info.protocolVersion)
|
print("Rojo: Protocol version:", info.protocolVersion)
|
||||||
print("Server version:", info.serverVersion)
|
print("Rojo: Server version:", info.serverVersion)
|
||||||
end)
|
end)
|
||||||
:catch(function(err)
|
:catch(function(err)
|
||||||
if err == Api.Error.ServerIdMismatch then
|
if err == Api.Error.ServerIdMismatch then
|
||||||
|
|
@ -119,7 +121,7 @@ function Plugin:stopPolling()
|
||||||
return Promise.resolve(false)
|
return Promise.resolve(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Stopped polling.")
|
print("Rojo Stopped polling server for changes.")
|
||||||
|
|
||||||
self._polling = false
|
self._polling = false
|
||||||
self._label.Enabled = false
|
self._label.Enabled = false
|
||||||
|
|
@ -168,7 +170,7 @@ function Plugin:startPolling()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Starting to poll...")
|
print("Rojo: Polling server for changes...")
|
||||||
|
|
||||||
self._polling = true
|
self._polling = true
|
||||||
self._label.Enabled = true
|
self._label.Enabled = true
|
||||||
|
|
@ -224,7 +226,14 @@ function Plugin:startPolling()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Plugin:syncIn()
|
function Plugin:syncIn()
|
||||||
print("Syncing from server...")
|
if self._syncInProgress then
|
||||||
|
warn("Rojo: Can't sync right now, because a sync is already in progress.")
|
||||||
|
|
||||||
|
return Promise.resolve()
|
||||||
|
end
|
||||||
|
|
||||||
|
self._syncInProgress = true
|
||||||
|
print("Rojo: Syncing from server...")
|
||||||
|
|
||||||
return self:api()
|
return self:api()
|
||||||
:andThen(function(api)
|
:andThen(function(api)
|
||||||
|
|
@ -242,9 +251,12 @@ function Plugin:syncIn()
|
||||||
|
|
||||||
self:_pull(api, info.project, routes)
|
self:_pull(api, info.project, routes)
|
||||||
|
|
||||||
print("Sync successful!")
|
self._syncInProgress = false
|
||||||
|
print("Rojo: Sync successful!")
|
||||||
end)
|
end)
|
||||||
:catch(function(err)
|
:catch(function(err)
|
||||||
|
self._syncInProgress = false
|
||||||
|
|
||||||
if err == Api.Error.ServerIdMismatch then
|
if err == Api.Error.ServerIdMismatch then
|
||||||
self:restart()
|
self:restart()
|
||||||
return self:syncIn()
|
return self:syncIn()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue