Contracts updated; IBackupEngine added

master
Inga 🏳‍🌈 7 years ago
parent 5b19fb1d28
commit c5e447308d
  1. 2
      EternalArrowBackup.sln
  2. 10
      Source/Contracts/MainBackupEngine/IBackupEngine.cs
  3. 17
      Source/Contracts/MainBackupEngine/IBackupReport.cs
  4. 3
      Source/Contracts/SourceStorage/ISourceDirectory.cs
  5. 3
      Source/Contracts/SourceStorage/ISourceStorage.cs
  6. 22
      Source/Contracts/TargetStorage/ITargetDirectory.cs
  7. 3
      Source/Contracts/TargetStorage/ITargetStorageForRecovery.cs

@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.26430.14
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{A79A4872-4289-4429-B616-3E8CEC71ECB8}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{A79A4872-4289-4429-B616-3E8CEC71ECB8}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EternalArrowBackup.Contracts", "Source\Contracts\EternalArrowBackup.Contracts.csproj", "{9A363462-23E2-49FB-A65C-7B1CA1400046}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EternalArrowBackup.Contracts", "Source\Contracts\EternalArrowBackup.Contracts.csproj", "{9A363462-23E2-49FB-A65C-7B1CA1400046}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -0,0 +1,10 @@
namespace EternalArrowBackup.Contracts.BackupEngine
{
using System.Threading;
using System.Threading.Tasks;
public interface IBackupEngine
{
Task<IBackupReport> BackupAll(CancellationToken ct);
}
}

@ -0,0 +1,17 @@
using System;
namespace EternalArrowBackup.Contracts.BackupEngine
{
public class IBackupReport
{
public long FilesUploaded { get; }
public long BytesUploaded { get; }
public long FilesUpdated { get; }
public long FilesProcessed { get; }
public Exception[] Errors { get; }
}
}

@ -1,6 +1,7 @@
namespace EternalArrowBackup.Contracts.SourceStorage namespace EternalArrowBackup.Contracts.SourceStorage
{ {
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
public interface ISourceDirectory public interface ISourceDirectory
@ -9,6 +10,6 @@
Task<ISourceFile> GetFile(string filename); Task<ISourceFile> GetFile(string filename);
IObservable<ISourceFile> GetAllFiles(); IObservable<ISourceFile> GetAllFiles(CancellationToken ct);
} }
} }

@ -1,12 +1,13 @@
namespace EternalArrowBackup.Contracts.SourceStorage namespace EternalArrowBackup.Contracts.SourceStorage
{ {
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
public interface ISourceStorage public interface ISourceStorage
{ {
Task<ISourceDirectory> GetDirectory(string normalizedRelativePath); Task<ISourceDirectory> GetDirectory(string normalizedRelativePath);
IObservable<ISourceDirectory> GetAllDirectories(); IObservable<ISourceDirectory> GetAllDirectories(CancellationToken ct);
} }
} }

@ -1,14 +1,30 @@
namespace EternalArrowBackup.Contracts.TargetStorage namespace EternalArrowBackup.Contracts.TargetStorage
{ {
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
public interface ITargetDirectory public interface ITargetDirectory
{ {
Task UploadFile(string filename, byte[] content, string hash); /// <summary>
/// Uploads new content to the target directory, and adds new entity with DateTime.UtcNow to the list of files
/// </summary>
/// <param name="filename">File name</param>
/// <param name="content">Content</param>
/// <param name="hash">File hash</param>
/// <returns>Task</returns>
Task UploadNewContent(string filename, byte[] content, string hash);
Task<ITargetFile> GetFile(string filename, string hash); /// <summary>
/// Adds new entity with DateTime.UtcNow to the list of files.
///
/// Example: file "abc.txt" with content "qwe" (v1) was replaced with "rty" (v2), and then was replaced with "qwe" (v3) again.
/// The client should <see cref="UploadNewContent(string, byte[], string)"/> for v1 and v2, and then call this method (passing v1 FileInfo to it) for v3.
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
Task UpdateExistingContent(ITargetFile file);
IObservable<ITargetFile> GetAllFiles(); IObservable<ITargetFile> GetAllFiles(CancellationToken ct);
} }
} }

@ -1,9 +1,10 @@
namespace EternalArrowBackup.Contracts.TargetStorage namespace EternalArrowBackup.Contracts.TargetStorage
{ {
using System; using System;
using System.Threading;
public interface ITargetStorageForRecovery public interface ITargetStorageForRecovery
{ {
IObservable<ITargetDirectory> GetAllDirectories(); IObservable<ITargetDirectory> GetAllDirectories(CancellationToken ct);
} }
} }

Loading…
Cancel
Save