Browse Source

Remove methods for creating "Acedia structure"

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
0e328b48ce
  1. 10
      sources/Data/Database/Local/LocalDatabase.uc
  2. 32
      sources/Data/Database/Local/LocalDatabaseInstance.uc

10
sources/Data/Database/Local/LocalDatabase.uc

@ -27,7 +27,6 @@ class LocalDatabase extends AcediaObject
var config private string root; var config private string root;
var config private bool createIfMissing; var config private bool createIfMissing;
var config private bool enforceAcediaStructure;
public final function Text GetPackageName() public final function Text GetPackageName()
{ {
@ -44,12 +43,6 @@ public final function Text GetRootName()
return __().text.FromString(root); return __().text.FromString(root);
} }
public final function bool RequiresAcediaStructure()
{
return enforceAcediaStructure;
}
/** /**
* Changes caller's root name. * Changes caller's root name.
* *
@ -110,6 +103,5 @@ public final function DeleteSelf()
defaultproperties defaultproperties
{ {
enforceAcediaStructure = false createIfMissing = false
createIfMissing = false
} }

32
sources/Data/Database/Local/LocalDatabaseInstance.uc

@ -86,8 +86,6 @@ var private DBTask lastTask;
// Remember task's life version to make sure we still have the correct copy // Remember task's life version to make sure we still have the correct copy
var private int lastTaskLifeVersion; var private int lastTaskLifeVersion;
var private LoggerAPI.Definition warnDataErasedForAcediaStructure;
protected function Constructor() protected function Constructor()
{ {
_.unreal.OnTick(self).connect = CompleteAllTasks; _.unreal.OnTick(self).connect = CompleteAllTasks;
@ -343,38 +341,9 @@ public final function Initialize(LocalDatabase config, DBRecord root)
configEntry = config; configEntry = config;
rootRecord = root; rootRecord = root;
if (config.RequiresAcediaStructure()) {
CreateAcediaStructure(config);
}
ScheduleDiskUpdate(); ScheduleDiskUpdate();
} }
// Create JSON object at "/users" if something else (or nothing)
// is stored there
private final function CreateAcediaStructure(LocalDatabase config)
{
local DataType usersType;
local JSONPointer usersPointer;
local AssociativeArray emptyObject;
if (config == none) return;
if (rootRecord == none) return;
usersPointer = _.json.Pointer(P("/users"));
usersType = rootRecord.GetObjectType(usersPointer);
if (usersType != JSON_Object)
{
emptyObject = _.collections.EmptyAssociativeArray();
rootRecord.SaveObject(usersPointer, emptyObject);
emptyObject.FreeSelf();
if (usersType != JSON_Undefined)
{
_.logger.Auto(warnDataErasedForAcediaStructure)
.Arg(config.GetPackageName());
}
}
usersPointer.FreeSelf();
}
/** /**
* Returns config object that describes caller database. * Returns config object that describes caller database.
* *
@ -390,5 +359,4 @@ public final function LocalDatabase GetConfig()
defaultproperties defaultproperties
{ {
usesObjectPool = false usesObjectPool = false
warnDataErasedForAcediaStructure = (l=LOG_Warning,m="Data was erased at \"/users\" in database \"%1\" to create Acedia's database structure.")
} }
Loading…
Cancel
Save