[longomatch] Add the backup date to the database correctly
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add the backup date to the database correctly
- Date: Tue, 16 Apr 2013 19:49:45 +0000 (UTC)
commit ed1b69279400539e6f488c532466e2d77420d050
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Apr 10 08:25:58 2013 +0200
Add the backup date to the database correctly
LongoMatch.Services/Services/DataBase.cs | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.Services/Services/DataBase.cs b/LongoMatch.Services/Services/DataBase.cs
index cac9d4a..12cacfa 100644
--- a/LongoMatch.Services/Services/DataBase.cs
+++ b/LongoMatch.Services/Services/DataBase.cs
@@ -322,13 +322,24 @@ namespace LongoMatch.DB
private void GetBackupDate () {
lastBackup = GetObject<BackupDate> ();
- if (lastBackup == null)
+ if (lastBackup == null) {
lastBackup = new BackupDate {Date = DateTime.UtcNow};
+ UpdateBackupDate(true);
+ }
Log.Information("DB last backup: "+ lastBackup.Date.ToShortDateString());
}
- private void UpdateBackupDate () {
- UpdateObject(lastBackup);
+ private void UpdateBackupDate (bool create) {
+ if (create) {
+ IObjectContainer db = Db4oFactory.OpenFile(file);
+ try {
+ db.Store(lastBackup);
+ } finally {
+ db.Close();
+ }
+ } else {
+ UpdateObject(lastBackup);
+ }
}
private T GetObject<T>() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]