Fix syncing projects that mention properties with elevated permissions.

Permission errors aren't reported since I'm not sure what the user could do about them.
Some properties can be set in the model format but not in live-sync mode, like HttpEnabled.
This commit is contained in:
Lucien Greathouse
2019-01-10 16:57:44 -08:00
parent 1e1b409f8b
commit 7b84fce737

View File

@@ -67,15 +67,34 @@ local function setProperty(instance, key, value)
return return
end end
local ok, err = pcall(function() -- If we don't have permissions to access this value at all, we can skip it.
if instance[key] ~= value then local readSuccess, existingValue = pcall(function()
return instance[key]
end)
if not readSuccess then
-- An error will be thrown if there was a permission issue or if the
-- property doesn't exist. In the latter case, we should tell the user
-- because it's probably their fault.
if existingValue:find("lacking permission") then
Logging.trace("Permission error reading property %s on class %s", tostring(key), instance.ClassName)
return
else
error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, existingValue), 2)
end
end
local writeSuccess, err = pcall(function()
if existingValue ~= value then
instance[key] = value instance[key] = value
end end
end) end)
if not ok then if not writeSuccess then
error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2) error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2)
end end
return true
end end
local Reconciler = {} local Reconciler = {}