OneDrive Backup

OneDrive Backup
This commit is contained in:
2023-07-28 22:36:06 +07:00
parent e1c6e91a0a
commit d70d81ebdf
244 changed files with 75229 additions and 0 deletions
@@ -0,0 +1,25 @@
using hassio_onedrive_backup.Contracts;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hassio_onedrive_backup.Storage
{
internal class AddonOptionsReader
{
public static AddonOptions ReadOptions(string path = "options.json")
{
if (File.Exists(path) == false)
{
throw new NotSupportedException($"{path} not found");
}
string optionContents = File.ReadAllText(path);
var options = JsonConvert.DeserializeObject<AddonOptions>(optionContents);
return options!;
}
}
}
+32
View File
@@ -0,0 +1,32 @@
namespace hassio_onedrive_backup.Storage
{
internal class LocalStorage
{
public const string TempFolder = "../tmp";
private const string oldTempFolder = "./tmp";
public static void InitializeTempStorage()
{
// Legacy cleanup
if (Directory.Exists(oldTempFolder))
{
ConsoleLogger.LogVerbose($"Deleting deprecated temp storage folder");
Directory.Delete(oldTempFolder, true);
}
// Clear temporary storage
if (Directory.Exists(TempFolder))
{
if (Directory.EnumerateFiles($"{TempFolder}").Any())
{
ConsoleLogger.LogVerbose("Cleaning up temporary artifcats");
}
Directory.Delete(TempFolder, true);
}
// (Re)Create temporary directory
Directory.CreateDirectory(TempFolder);
}
}
}