public DataBase(string dbDirPath)
{
serializer = new Serializer ();
dbName = Path.GetFileNameWithoutExtension (dbDirPath);
dbPath = Path.Combine (dbDirPath, Path.GetFileName (dbDirPath));
this.dbDirPath = dbDirPath;
if (!Directory.Exists (dbDirPath)) {
Directory.CreateDirectory (dbDirPath);
}
if (File.Exists (dbPath)) {
try {
projectsDB = serializer.Load<LiteDB> (dbPath);
projectsDB.DBPath = dbPath;
} catch (Exception e) {
Log.Exception (e);
}
}
if (projectsDB == null) {
Reload ();
}
DateTime now = DateTime.UtcNow;
if (projectsDB.LastBackup + maxDaysWithoutBackup < now) {
Backup ();
}
}