diff --git a/Flawless.Communication/Flawless.Communication.csproj b/Flawless.Communication/Flawless.Communication.csproj
index 40b98ef..5db5616 100644
--- a/Flawless.Communication/Flawless.Communication.csproj
+++ b/Flawless.Communication/Flawless.Communication.csproj
@@ -6,4 +6,8 @@
net9.0
+
+
+
+
diff --git a/Flawless.Communication/Request/CommitRequest.cs b/Flawless.Communication/Request/CommitRequest.cs
index 23b2122..4d21065 100644
--- a/Flawless.Communication/Request/CommitRequest.cs
+++ b/Flawless.Communication/Request/CommitRequest.cs
@@ -1,10 +1,13 @@
+using Flawless.Core.Modal;
+
namespace Flawless.Communication.Request;
public class CommitRequest
{
+
public required string Message { get; set; }
- public required string[] WorkspaceSnapshot { get; set; }
+ public required WorkspaceFile[] WorkspaceSnapshot { get; set; }
public string[]? RequiredDepots { get; set; }
diff --git a/Flawless.Core/BinaryDataFormat/DataTransformer.cs b/Flawless.Core/BinaryDataFormat/DataTransformer.cs
index 0574e6e..638b3f2 100644
--- a/Flawless.Core/BinaryDataFormat/DataTransformer.cs
+++ b/Flawless.Core/BinaryDataFormat/DataTransformer.cs
@@ -11,7 +11,6 @@ public static class DataTransformer
{
depotStream.Seek(8, SeekOrigin.Current);
var val = depotStream.ReadByte();
- depotStream.Seek(-9, SeekOrigin.Current);
if (val < 0) ;
@@ -74,7 +73,7 @@ public static class DataTransformer
return depotStream.ReadSlice((long) size);
}
- public static async IAsyncEnumerable ExtractDepotFileInfoMapAsync(ulong fileMapSize, Stream depotStream)
+ public static async IAsyncEnumerable ExtractDepotFileInfoMapAsync(Stream depotStream, ulong fileMapSize)
{
var splitor = '$';
depotStream.Seek((long) fileMapSize, SeekOrigin.End);
@@ -87,6 +86,7 @@ public static class DataTransformer
var path = string.Empty;
var size = 0UL;
var offset = 0UL;
+ DateTime modifyTime = default;
// Read loop
while (true)
@@ -101,11 +101,12 @@ public static class DataTransformer
if (c != splitor) builder.Append(c);
else
{
- switch ((state = (state + 1) % 3))
+ switch ((state = (state + 1) % 4))
{
case 0: path = builder.ToString(); break;
case 1: size = ulong.Parse(builder.ToString()); break;
- case 2: offset = ulong.Parse(builder.ToString()); break;
+ case 2: modifyTime = DateTime.FromBinary(long.Parse(builder.ToString())); break;
+ case 3: offset = ulong.Parse(builder.ToString()); break;
}
builder.Clear();
@@ -119,7 +120,7 @@ public static class DataTransformer
// Do output at here.
- yield return new DepotFileInfo(offset, size, path);
+ yield return new DepotFileInfo(offset, size, modifyTime, path);
}
diff --git a/Flawless.Core/Modal/CommitManifest.cs b/Flawless.Core/Modal/CommitManifest.cs
index e172b58..ea0db22 100644
--- a/Flawless.Core/Modal/CommitManifest.cs
+++ b/Flawless.Core/Modal/CommitManifest.cs
@@ -1,4 +1,4 @@
namespace Flawless.Core.Modal;
[Serializable]
-public record struct CommitManifest(Guid ManifestId, DepotLabel Depot, string[] FilePaths);
\ No newline at end of file
+public record struct CommitManifest(Guid ManifestId, DepotLabel Depot, WorkspaceFile[] FilePaths);
\ No newline at end of file
diff --git a/Flawless.Core/Modal/DepotFileInfo.cs b/Flawless.Core/Modal/DepotFileInfo.cs
index 1f2b261..d2ea03e 100644
--- a/Flawless.Core/Modal/DepotFileInfo.cs
+++ b/Flawless.Core/Modal/DepotFileInfo.cs
@@ -1,4 +1,4 @@
namespace Flawless.Core.Modal;
[Serializable]
-public record struct DepotFileInfo(ulong Offset, ulong Size, string Path);
\ No newline at end of file
+public record struct DepotFileInfo(ulong Offset, ulong Size, DateTime ModifyTime, string Path);
\ No newline at end of file
diff --git a/Flawless.Core/Modal/DepotLabel.cs b/Flawless.Core/Modal/DepotLabel.cs
index 5c4866d..d4a94f4 100644
--- a/Flawless.Core/Modal/DepotLabel.cs
+++ b/Flawless.Core/Modal/DepotLabel.cs
@@ -3,4 +3,4 @@
namespace Flawless.Core.Modal;
[Serializable]
-public record struct DepotLabel(HashId Id, HashId[] Dependency);
\ No newline at end of file
+public record struct DepotLabel(Guid Id, long Length, Guid[] Dependency);
\ No newline at end of file
diff --git a/Flawless.Core/Modal/WorkspaceFile.cs b/Flawless.Core/Modal/WorkspaceFile.cs
new file mode 100644
index 0000000..76a6e26
--- /dev/null
+++ b/Flawless.Core/Modal/WorkspaceFile.cs
@@ -0,0 +1,33 @@
+namespace Flawless.Core.Modal;
+
+public struct WorkspaceFile : IEquatable
+{
+ public required DateTime ModifyTime;
+
+ public required string WorkPath;
+
+ public bool Equals(WorkspaceFile other)
+ {
+ return ModifyTime.Equals(other.ModifyTime) && WorkPath == other.WorkPath;
+ }
+
+ public override bool Equals(object? obj)
+ {
+ return obj is WorkspaceFile other && Equals(other);
+ }
+
+ public override int GetHashCode()
+ {
+ return HashCode.Combine(ModifyTime, WorkPath);
+ }
+
+ public static bool operator ==(WorkspaceFile left, WorkspaceFile right)
+ {
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(WorkspaceFile left, WorkspaceFile right)
+ {
+ return !left.Equals(right);
+ }
+}
\ No newline at end of file
diff --git a/Flawless.Server/Controllers/RepositoryControl.cs b/Flawless.Server/Controllers/RepositoryControl.cs
index cf8bdbf..4fbc99c 100644
--- a/Flawless.Server/Controllers/RepositoryControl.cs
+++ b/Flawless.Server/Controllers/RepositoryControl.cs
@@ -1,6 +1,11 @@
-using Flawless.Communication.Request;
+using System.Collections.Concurrent;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using Flawless.Communication.Request;
using Flawless.Communication.Response;
using Flawless.Communication.Shared;
+using Flawless.Core.BinaryDataFormat;
+using Flawless.Core.Modal;
using Flawless.Server.Models;
using Flawless.Server.Services;
using Flawless.Server.Utility;
@@ -15,12 +20,13 @@ namespace Flawless.Server.Controllers;
public class RepositoryControl(
UserManager userManager,
AppDbContext dbContext,
- PathTransformer transformer) : ControllerBase
+ PathTransformer transformer,
+ JsonSerializerOptions serializerOpt) : ControllerBase
{
public class FormCommitRequest : CommitRequest
{
- public IFormFile Depot { get; set; }
+ public IFormFile? Depot { get; set; }
}
@@ -36,22 +42,31 @@ public class RepositoryControl(
return true;
}
-
- [HttpGet("fetch/manifest/{commitId}")]
- public async Task DownloadManifestAsync(string userName, string repositoryName, string commitId)
+ private async ValueTask