diff --git a/GBase/FileHandling/FileHandler.cs b/GBase/FileHandling/FileHandler.cs
index 1e997d2..e4a708b 100644
--- a/GBase/FileHandling/FileHandler.cs
+++ b/GBase/FileHandling/FileHandler.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using GBase.Interfaces;
@@ -17,7 +18,7 @@ namespace GBase.FileHandling
///
/// Internal file handler
///
- public class FileHandler : IFileHandler
+ public class FileHandler : IFileHandler //TODO: Don't let file handler call data handler, have them parallel and have file handler only handle the files. this also makes more sense with the dataHandlerPool
{
///
/// The file extension for all GBase tables
@@ -27,6 +28,8 @@ namespace GBase.FileHandling
private readonly IDataHandlerPool _dataHandlerPool;
private string _path;
+ private readonly List<(object entry, FileStream file, string filePath, bool inUse)> _files;
+
///
/// Internal file handler
///
@@ -34,6 +37,7 @@ namespace GBase.FileHandling
public FileHandler(IDataHandlerPool dataHandlerPool)
{
_dataHandlerPool = dataHandlerPool;
+ _files = new List<(object entry, FileStream file, string filePath, bool inUse)>();
}
///
@@ -61,12 +65,19 @@ namespace GBase.FileHandling
IDataHandler dataHandler = await _dataHandlerPool.RequestDataHandler(this, false, cancellationToken);
await dataHandler.AddEntry(entry, table, entryFile, cancellationToken);
+
+ _files.Add((entry, entryFile, filePath, false));
}
- public Task RemoveEntry(T entry)
+ public async Task RemoveEntry(T entry)
{
- //remove entry file
- throw new NotImplementedException();
+ var file = _files.FirstOrDefault(f => f.entry.Equals(entry));
+ if (file == default)
+ return false;
+
+ await file.file.DisposeAsync();
+ File.Delete(file.filePath);
+ return true;
}
///
@@ -74,11 +85,12 @@ namespace GBase.FileHandling
///
/// The of the property
/// The of the property
+ ///
/// The name of the property
/// The value to set
///
/// A to await
- public async Task SetValue(string propertyName, TProperty value, CancellationToken cancellationToken)
+ public async Task SetValue(T entry, string propertyName, TProperty value, CancellationToken cancellationToken)
{
IDataHandler dataHandler = await _dataHandlerPool.RequestDataHandler(this, false, cancellationToken);
await dataHandler.SetValue(TODO, propertyName, value, cancellationToken);
diff --git a/GBase/Interfaces/FileHandling/IFileHandler.cs b/GBase/Interfaces/FileHandling/IFileHandler.cs
index 3e3e715..b617c6d 100644
--- a/GBase/Interfaces/FileHandling/IFileHandler.cs
+++ b/GBase/Interfaces/FileHandling/IFileHandler.cs
@@ -31,11 +31,12 @@ namespace GBase.Interfaces.FileHandling
///
/// The of the property
/// The of the property
+ ///
/// The name of the property
/// The value to set
///
/// A to await
- Task SetValue(string propertyName, TProperty value, CancellationToken cancellationToken);
+ Task SetValue(T entry, string propertyName, TProperty value, CancellationToken cancellationToken);
///
/// Remove the value for the given property