feat: 完成将要删除的旧文件备份
1. websocket pipe测试 2. 需要更多测试 3. 需要前端操作页面
This commit is contained in:
parent
468701b9ed
commit
d572e9466e
8 changed files with 59 additions and 13 deletions
|
@ -259,15 +259,21 @@ public static class DirExtension
|
||||||
{
|
{
|
||||||
if (child is Dir childDir)
|
if (child is Dir childDir)
|
||||||
{
|
{
|
||||||
fileDirOp.DirCreate(childDir, false);
|
if (childDir.NextOp != NextOpType.Del)
|
||||||
f(childDir, fileDirOp);
|
{
|
||||||
|
fileDirOp.DirCreate(childDir, false);
|
||||||
|
f(childDir, fileDirOp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (child is File childFile)
|
if (child is File childFile)
|
||||||
{
|
{
|
||||||
fileDirOp.FileCreate(child.FormatedPath, childFile.MTime);
|
if (childFile.NextOp != NextOpType.Del)
|
||||||
|
{
|
||||||
|
fileDirOp.FileCreate(child.FormatedPath, childFile.MTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,6 +167,37 @@ public class FileDirOpForPack(string srcRootPath, string dstRootPath) : FileDirO
|
||||||
|
|
||||||
public class FileDirOpForUnpack(string srcRootPath, string dstRootPath) : FileDirOpStra
|
public class FileDirOpForUnpack(string srcRootPath, string dstRootPath) : FileDirOpStra
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 备份文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="absolutePath"> 源文件位置,将要删除的或者替换的</param>
|
||||||
|
private void BacklogFile(string absolutePath)
|
||||||
|
{
|
||||||
|
var dstPath = absolutePath.Replace(DstRootPath, SrcRootPath);
|
||||||
|
|
||||||
|
var dstDirPath =
|
||||||
|
Path.GetDirectoryName(dstPath) ?? throw new NullReferenceException("父路径不存在!");
|
||||||
|
if (!Directory.Exists(dstDirPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dstDirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
//文件时间不会更改
|
||||||
|
System.IO.File.Move(absolutePath, dstPath + ".bak", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BacklogDir(string absolutePath)
|
||||||
|
{
|
||||||
|
var dstPath = absolutePath.Replace(DstRootPath, SrcRootPath);
|
||||||
|
var dstDirPath =
|
||||||
|
Path.GetDirectoryName(dstPath) ?? throw new NullReferenceException("父路径不存在!");
|
||||||
|
if (!Directory.Exists(dstDirPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dstDirPath);
|
||||||
|
}
|
||||||
|
Directory.Move(absolutePath, dstPath);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解压缩,必须首先调用
|
/// 解压缩,必须首先调用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -273,17 +304,20 @@ public class FileDirOpForUnpack(string srcRootPath, string dstRootPath) : FileDi
|
||||||
|
|
||||||
public override void FileModify(string absolutePath, DateTime mtime)
|
public override void FileModify(string absolutePath, DateTime mtime)
|
||||||
{
|
{
|
||||||
|
BacklogFile(absolutePath);
|
||||||
this.FileCreate(absolutePath, mtime);
|
this.FileCreate(absolutePath, mtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FileDel(string absolutePath)
|
public override void FileDel(string absolutePath)
|
||||||
{
|
{
|
||||||
|
BacklogFile(absolutePath);
|
||||||
System.IO.File.Delete(absolutePath);
|
System.IO.File.Delete(absolutePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DirDel(Dir dir, bool IsRecursion = true)
|
public override void DirDel(Dir dir, bool IsRecursion = true)
|
||||||
{
|
{
|
||||||
System.IO.Directory.Delete(dir.FormatedPath, IsRecursion);
|
BacklogDir(dir.FormatedPath);
|
||||||
|
//System.IO.Directory.Delete(dir.FormatedPath, IsRecursion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@ public class LocalSyncServer
|
||||||
#pragma warning disable CA2211 // Non-constant fields should not be visible
|
#pragma warning disable CA2211 // Non-constant fields should not be visible
|
||||||
public static string TempRootFile = "C:/TempPack";
|
public static string TempRootFile = "C:/TempPack";
|
||||||
public static string SqlPackageAbPath = "sqlpackage";
|
public static string SqlPackageAbPath = "sqlpackage";
|
||||||
public static string MsdeployAbPath = "msdeploy";
|
|
||||||
|
//public static string MsdeployAbPath = "msdeploy";
|
||||||
|
|
||||||
//与visual studio 匹配的Msbuild 路径。在vs 中打开power shell 命令行,使用 `(get-Command -Name msbuild).Source `
|
//与visual studio 匹配的Msbuild 路径。在vs 中打开power shell 命令行,使用 `(get-Command -Name msbuild).Source `
|
||||||
public static string MSBuildAbPath = "MSBuild";
|
public static string MSBuildAbPath = "MSBuild";
|
||||||
|
|
|
@ -11,9 +11,10 @@ IConfiguration _configuration = configurationBuilder.Build();
|
||||||
LocalSyncServer.TempRootFile = _configuration["TempDir"] ?? "C:/TempPack";
|
LocalSyncServer.TempRootFile = _configuration["TempDir"] ?? "C:/TempPack";
|
||||||
LocalSyncServer.SqlPackageAbPath =
|
LocalSyncServer.SqlPackageAbPath =
|
||||||
_configuration["SqlPackageAbPath"] ?? "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
_configuration["SqlPackageAbPath"] ?? "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
||||||
LocalSyncServer.MsdeployAbPath =
|
|
||||||
_configuration["MsdeployAbPath"]
|
//LocalSyncServer.MsdeployAbPath =
|
||||||
?? "C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe";
|
// _configuration["MsdeployAbPath"]
|
||||||
|
// ?? "C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe";
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,7 @@ public class DiffFileAndPackHelper(LocalSyncServer context)
|
||||||
};
|
};
|
||||||
e.LocalDirInfo.ExtractInfo(e.CherryPicks, e.Excludes);
|
e.LocalDirInfo.ExtractInfo(e.CherryPicks, e.Excludes);
|
||||||
});
|
});
|
||||||
|
|
||||||
//将配置信息发送到remoteServer
|
//将配置信息发送到remoteServer
|
||||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||||
Context
|
Context
|
||||||
|
@ -286,6 +287,9 @@ public class DiffFileAndPackHelper(LocalSyncServer context)
|
||||||
Context.NotNullSyncConfig.LocalRootPath,
|
Context.NotNullSyncConfig.LocalRootPath,
|
||||||
LocalSyncServer.TempRootFile + "/" + Context.NotNullSyncConfig.Id.ToString()
|
LocalSyncServer.TempRootFile + "/" + Context.NotNullSyncConfig.Id.ToString()
|
||||||
);
|
);
|
||||||
|
Directory.CreateDirectory(
|
||||||
|
LocalSyncServer.TempRootFile + "/" + Context.NotNullSyncConfig.Id.ToString()
|
||||||
|
);
|
||||||
Context.NotNullSyncConfig.DirFileConfigs.ForEach(e =>
|
Context.NotNullSyncConfig.DirFileConfigs.ForEach(e =>
|
||||||
{
|
{
|
||||||
if (e.DiffDirInfo != null)
|
if (e.DiffDirInfo != null)
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"TempDir": "D:/TempPack",
|
"TempDir": "D:/TempPack",
|
||||||
"SqlPackageAbPath": "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe",
|
"SqlPackageAbPath": "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe",
|
||||||
"MsdeployAbPath": "C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe",
|
//"MsdeployAbPath": "C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe",
|
||||||
"MSBuildAbPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe"
|
"MSBuildAbPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ public class PipeSeed : IDisposable
|
||||||
Name = "Test",
|
Name = "Test",
|
||||||
RemoteUrl = "D:/FileSyncTest/dtemp",
|
RemoteUrl = "D:/FileSyncTest/dtemp",
|
||||||
RemotePwd = "t123",
|
RemotePwd = "t123",
|
||||||
IsDeployDb = true,
|
IsDeployDb = false,
|
||||||
IsDeployProject = true,
|
IsDeployProject = false,
|
||||||
LocalProjectAbsolutePath = "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
LocalProjectAbsolutePath = "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
||||||
LocalRootPath = "D:/FileSyncTest/src",
|
LocalRootPath = "D:/FileSyncTest/src",
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class PipeTest
|
||||||
p4.Other = p3;
|
p4.Other = p3;
|
||||||
LocalSyncServer.TempRootFile = "D:/FileSyncTest/stemp";
|
LocalSyncServer.TempRootFile = "D:/FileSyncTest/stemp";
|
||||||
RemoteSyncServer.SqlPackageAbPath = "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
RemoteSyncServer.SqlPackageAbPath = "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
||||||
LocalSyncServer.MsdeployAbPath =
|
//LocalSyncServer.MsdeployAbPath =
|
||||||
"C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe";
|
// "C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe";
|
||||||
LocalSyncServer.SqlPackageAbPath = "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
LocalSyncServer.SqlPackageAbPath = "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
||||||
LocalSyncServer.MSBuildAbPath =
|
LocalSyncServer.MSBuildAbPath =
|
||||||
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe";
|
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe";
|
||||||
|
|
Loading…
Reference in a new issue