| 194 | } |
| 195 | |
| 196 | LuaCallbacks VersioningDatabase::makeVersioningCallbacks() const { |
| 197 | LuaCallbacks versioningCallbacks; |
| 198 | |
| 199 | versioningCallbacks.registerCallback("loadVersionedJson", [this](String const& storagePath) { |
| 200 | try { |
| 201 | auto& root = Root::singleton(); |
| 202 | String filePath = File::fullPath(root.toStoragePath(storagePath)); |
| 203 | String basePath = File::fullPath(root.toStoragePath(".")); |
| 204 | if (!filePath.beginsWith(basePath)) |
| 205 | throw VersioningDatabaseException::format( |
| 206 | "Cannot load external VersionedJson outside of the Root storage path"); |
| 207 | auto loadedJson = VersionedJson::readFile(filePath); |
| 208 | return updateVersionedJson(loadedJson).content; |
| 209 | } catch (IOException const& e) { |
| 210 | Logger::debug( |
| 211 | "Unable to load versioned JSON file {} in versioning script: {}", storagePath, outputException(e, false)); |
| 212 | return Json(); |
| 213 | } |
| 214 | }); |
| 215 | |
| 216 | return versioningCallbacks; |
| 217 | } |
| 218 | |
| 219 | } |
nothing calls this directly
no test coverage detected