diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs b/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs
index 43f266ef53c7732dc0e3f6635cf3fe590892def5..bb0851f2176561de9f6075443242cbef5120f73e 100644
--- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs
+++ b/src/c#/GeneralUpdate.Differential/ContentProvider/FileNode.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace GeneralUpdate.Differential.ContentProvider
{
@@ -24,6 +24,8 @@ namespace GeneralUpdate.Differential.ContentProvider
public int RightType { get; set; }
+ public string RelativePath { get; set; }
+
#endregion Public Properties
#region Constructors
diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs b/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs
index bf15a96155a8e61a45b36f7dcb763e58d1d32097..f8a6f8fc61872b2c36a00fa7e67a1304f69b88a3 100644
--- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs
+++ b/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs
@@ -1,4 +1,4 @@
-using GeneralUpdate.Core.HashAlgorithms;
+using GeneralUpdate.Core.HashAlgorithms;
using GeneralUpdate.Differential.Common;
using System;
using System.Collections.Generic;
@@ -48,8 +48,8 @@ namespace GeneralUpdate.Differential.ContentProvider
{
var leftFileNodes = Read(leftPath);
var rightFileNodes = Read(rightPath);
- var rightNodeDic = rightFileNodes.ToDictionary(x => x.Name, x => x);
- var filesOnlyInLeft = leftFileNodes.Where(f => !rightNodeDic.ContainsKey(f.Name)).ToList();
+ var rightNodeDic = rightFileNodes.ToDictionary(x => x.RelativePath, x => x);
+ var filesOnlyInLeft = leftFileNodes.Where(f => !rightNodeDic.ContainsKey(f.RelativePath)).ToList();
return filesOnlyInLeft;
});
}
@@ -62,10 +62,14 @@ namespace GeneralUpdate.Differential.ContentProvider
/// Recursively read all files in the folder path.
///
/// folder path.
+ /// folder root path.
/// different chalders.
- private IEnumerable Read(string path)
+ private IEnumerable Read(string path, string rootPath = null)
{
var resultFiles = new List();
+ if (string.IsNullOrEmpty(rootPath)) rootPath = path;
+ if (!rootPath.EndsWith("/")) rootPath += "/";
+ Uri rootUri = new Uri(rootPath);
foreach (var subPath in Directory.GetFiles(path))
{
if (IsMatchBlacklist(subPath)) continue;
@@ -73,11 +77,12 @@ namespace GeneralUpdate.Differential.ContentProvider
var hashAlgorithm = new Sha256HashAlgorithm();
var hash = hashAlgorithm.ComputeHash(subPath);
var subFileInfo = new FileInfo(subPath);
- resultFiles.Add(new FileNode() { Id = GetId(), Path = path, Name = subFileInfo.Name, Hash = hash, FullName = subFileInfo.FullName });
+ Uri subUri = new Uri(subFileInfo.FullName);
+ resultFiles.Add(new FileNode() { Id = GetId(), Path = path, Name = subFileInfo.Name, Hash = hash, FullName = subFileInfo.FullName, RelativePath = rootUri.MakeRelativeUri(subUri).ToString() });
}
foreach (var subPath in Directory.GetDirectories(path))
{
- resultFiles.AddRange(Read(subPath));
+ resultFiles.AddRange(Read(subPath, rootPath));
}
return resultFiles;
}