add the whole API stuff first iteration

This commit is contained in:
Stanley Dimant
2022-06-19 01:57:37 +02:00
parent 176eb2a344
commit 1312086a8d
10 changed files with 692 additions and 92 deletions

View File

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json;
using MareSynchronos.FileCacheDB;
using System.IO;
using MareSynchronos.API;
using MareSynchronos.Utils;
namespace MareSynchronos.Models
@@ -14,6 +15,16 @@ namespace MareSynchronos.Models
[JsonObject(MemberSerialization.OptIn)]
public class FileReplacement
{
public FileReplacementDto ToFileReplacementDto()
{
return new FileReplacementDto
{
GamePaths = GamePaths,
Hash = Hash,
ImcData = ImcData
};
}
private readonly string penumbraDirectory;
[JsonProperty]
@@ -88,13 +99,20 @@ namespace MareSynchronos.Models
var fileAddedDuringCompute = db.FileCaches.SingleOrDefault(f => f.Filepath == fi.FullName.ToLower());
if (fileAddedDuringCompute != null) return fileAddedDuringCompute.Hash;
db.Add(new FileCache()
try
{
Hash = hash,
Filepath = fi.FullName.ToLower(),
LastModifiedDate = fi.LastWriteTimeUtc.Ticks.ToString()
});
db.SaveChanges();
db.Add(new FileCache()
{
Hash = hash,
Filepath = fi.FullName.ToLower(),
LastModifiedDate = fi.LastWriteTimeUtc.Ticks.ToString()
});
db.SaveChanges();
}
catch (Exception ex)
{
PluginLog.Error(ex, "Error adding files to database. Most likely not an issue though.");
}
return hash;
}