From 73b8b4189bb0be7f818f78b9811e4691b1ee32d8 Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 4 Aug 2025 21:06:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E5=8F=91=E5=B8=83=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/BuildSyncTool.yml | 77 +++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/BuildSyncTool.yml diff --git a/.github/workflows/BuildSyncTool.yml b/.github/workflows/BuildSyncTool.yml new file mode 100644 index 0000000..4d5f1f0 --- /dev/null +++ b/.github/workflows/BuildSyncTool.yml @@ -0,0 +1,77 @@ +name: BuildSyncTool + +on: [push] + +jobs: + Build_win-x86: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + + - name: Build with dotnet + run: dotnet publish --configuration Release -r win-x86 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj + + - uses: actions/upload-artifact@v4 + with: + name: SyncTool_win-x86 + path: SyncTool/bin/Release/net8.0/win-x86/publish + + Build_win-x64: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + + - name: Build with dotnet + run: dotnet publish --configuration Release -r win-x64 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj + + - uses: actions/upload-artifact@v4 + with: + name: SyncTool_win-x64 + path: SyncTool/bin/Release/net8.0/win-x64/publish + + Build_linux-x64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + + - name: Build with dotnet + run: dotnet publish --configuration Release -r linux-x64 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj + + - uses: actions/upload-artifact@v4 + with: + name: SyncTool_linux-x64 + path: SyncTool/bin/Release/net8.0/linux-x64/publish + + Build_linux-arm64: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + + - name: Build with dotnet + run: dotnet publish --configuration Release -r linux-arm64 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj + + - uses: actions/upload-artifact@v4 + with: + name: SyncTool_linux-arm64 + path: SyncTool/bin/Release/net8.0/linux-arm64/publish \ No newline at end of file From f20705e660a21f2d0c540b8c198b03ad0ee855e8 Mon Sep 17 00:00:00 2001 From: lindexi Date: Tue, 5 Aug 2025 11:25:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SyncTool/Client/SyncOptions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SyncTool/Client/SyncOptions.cs b/SyncTool/Client/SyncOptions.cs index 3e31df3..e93ff1d 100644 --- a/SyncTool/Client/SyncOptions.cs +++ b/SyncTool/Client/SyncOptions.cs @@ -299,6 +299,14 @@ async Task RemoveRedundantFolder(List syncFolderPathInfoList return; } + if (!Directory.Exists(folder)) + { + // 如果文件夹不存在了,可能是之前删除了,不再继续 + // 什么情况可能导致文件夹不存在?如有这样的路径 A\B\C 结构 + // 之前进入到 A\B 时,将 B 删除了,那么 A\B\C 就会不存在 + continue; + } + if (Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories).Any()) { // 如果存在文件,则不是空文件夹,不能删除 From 1ecd7c0bf7c25377cc3070fcf1dc1fa019688549 Mon Sep 17 00:00:00 2001 From: lindexi Date: Tue, 5 Aug 2025 11:27:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E5=88=A0=E9=99=A4=E7=A9=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SyncTool/Client/SyncOptions.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SyncTool/Client/SyncOptions.cs b/SyncTool/Client/SyncOptions.cs index e93ff1d..ae24deb 100644 --- a/SyncTool/Client/SyncOptions.cs +++ b/SyncTool/Client/SyncOptions.cs @@ -348,6 +348,13 @@ async Task RemoveRedundantFolder(List syncFolderPathInfoList } } } + + foreach (var syncFolderPathInfo in syncFolderPathInfoList) + { + var folderPath = Path.Join(syncFolder, syncFolderPathInfo.RelativePath); + // 重新创建,防止误删空文件夹 + Directory.CreateDirectory(folderPath); + } } async Task DownloadFile(SyncFileInfo remoteSyncFileInfo)