-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Deprecated old history upgrader
- Loading branch information
Showing
8 changed files
with
115 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// TS3AudioBot - An advanced Musicbot for Teamspeak 3 | ||
// Copyright (C) 2017 TS3AudioBot contributors | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the Open Software License v. 3.0 | ||
// | ||
// You should have received a copy of the Open Software License along with this | ||
// program. If not, see <https://opensource.org/licenses/OSL-3.0>. | ||
|
||
namespace TS3AudioBot | ||
{ | ||
using History; | ||
using LiteDB; | ||
using System; | ||
using System.IO; | ||
|
||
public class DbStore : IDisposable | ||
{ | ||
private const string DbMetaInformationTable = "dbmeta"; | ||
|
||
private readonly LiteDatabase database; | ||
private readonly LiteCollection<DbMetaData> metaTable; | ||
|
||
// TODO rework config class with config rewok | ||
public DbStore(HistoryManagerData hmd) | ||
{ | ||
var historyFile = new FileInfo(hmd.HistoryFile); | ||
database = new LiteDatabase(historyFile.FullName); | ||
|
||
metaTable = database.GetCollection<DbMetaData>(DbMetaInformationTable); | ||
} | ||
|
||
public DbMetaData GetMetaData(string table) | ||
{ | ||
var meta = metaTable.FindById(table); | ||
if (meta == null) | ||
{ | ||
meta = new DbMetaData { Id = table, Version = 0, CustomData = null }; | ||
metaTable.Insert(meta); | ||
} | ||
return meta; | ||
} | ||
|
||
public void UpdateMetaData(DbMetaData metaData) | ||
{ | ||
metaTable.Update(metaData); | ||
} | ||
|
||
public LiteCollection<T> GetCollection<T>(string name) | ||
{ | ||
return database.GetCollection<T>(name); | ||
} | ||
|
||
public void CleanFile() | ||
{ | ||
database.Shrink(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
database.Dispose(); | ||
} | ||
} | ||
|
||
public class DbMetaData | ||
{ | ||
public string Id { get; set; } | ||
public int Version { get; set; } | ||
public object CustomData { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.