Skip to content

Commit

Permalink
Add protection against syncing non place projects (rojo-rbx#691)
Browse files Browse the repository at this point in the history
Closes rojo-rbx#113.

Does what it says on the tin. When you try to sync a non-place project,
it gives a clear message instead of crashing.
  • Loading branch information
boatbomber committed Jun 30, 2023
1 parent 2ff11b6 commit ec0f4f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* Fixed the diff visualizer of connected sessions. ([#674])
* Fixed disconnected session activity. ([#675])
* Skip confirming patches that contain only a datamodel name change. ([#688])
* Added protection against syncing a model to a place. ([#691])

[#668]: https://github.com/rojo-rbx/rojo/pull/668
[#674]: https://github.com/rojo-rbx/rojo/pull/674
[#675]: https://github.com/rojo-rbx/rojo/pull/675
[#688]: https://github.com/rojo-rbx/rojo/pull/688
[#691]: https://github.com/rojo-rbx/rojo/pull/691

## [7.3.0] - April 22, 2023
* Added `$attributes` to project format. ([#574])
Expand Down
16 changes: 16 additions & 0 deletions plugin/src/ServeSession.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@ function ServeSession:__initialSync(serverInfo)
Log.error("Could not compute a diff to catch up to the Rojo server: {:#?}", catchUpPatch)
end

for _, update in catchUpPatch.updated do
if
update.id == self.__instanceMap.fromInstances[game]
and update.changedClassName ~= nil
then
-- Non-place projects will try to update the classname of game from DataModel to
-- something like Folder, ModuleScript, etc. This would fail, so we exit with a clear
-- message instead of crashing.
return Promise.reject(
"Cannot sync a model as a place."
.. "\nEnsure Rojo is serving a project file that has a DataModel at the root of its tree and try again."
.. "\nSee project file docs: https://rojo.space/docs/v7/project-format/"
)
end
end

Log.trace("Computed hydration patch: {:#?}", debugPatch(catchUpPatch))

local userDecision = "Accept"
Expand Down

0 comments on commit ec0f4f4

Please sign in to comment.