Skip to content

Commit b8707e3

Browse files
authored
Merge pull request #175 from dotnet-campus/t/lindexi/SyncTool
尝试加上更多发布命令
2 parents 24aa325 + ec24267 commit b8707e3

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: BuildSyncTool
2+
3+
on: [push]
4+
5+
jobs:
6+
Build_win-x86:
7+
8+
runs-on: windows-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup .NET
13+
uses: actions/setup-dotnet@v1
14+
with:
15+
dotnet-version: 8.0.x
16+
17+
- name: Build with dotnet
18+
run: dotnet publish --configuration Release -r win-x86 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj
19+
20+
- uses: actions/upload-artifact@v4
21+
with:
22+
name: SyncTool_win-x86
23+
path: SyncTool/bin/Release/net8.0/win-x86/publish
24+
25+
Build_win-x64:
26+
27+
runs-on: windows-latest
28+
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Setup .NET
32+
uses: actions/setup-dotnet@v1
33+
with:
34+
dotnet-version: 8.0.x
35+
36+
- name: Build with dotnet
37+
run: dotnet publish --configuration Release -r win-x64 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj
38+
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: SyncTool_win-x64
42+
path: SyncTool/bin/Release/net8.0/win-x64/publish
43+
44+
Build_linux-x64:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
48+
- name: Setup .NET
49+
uses: actions/setup-dotnet@v1
50+
with:
51+
dotnet-version: 8.0.x
52+
53+
- name: Build with dotnet
54+
run: dotnet publish --configuration Release -r linux-x64 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj
55+
56+
- uses: actions/upload-artifact@v4
57+
with:
58+
name: SyncTool_linux-x64
59+
path: SyncTool/bin/Release/net8.0/linux-x64/publish
60+
61+
Build_linux-arm64:
62+
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v2
66+
- name: Setup .NET
67+
uses: actions/setup-dotnet@v1
68+
with:
69+
dotnet-version: 8.0.x
70+
71+
- name: Build with dotnet
72+
run: dotnet publish --configuration Release -r linux-arm64 /p:PublishSingleFile=true --self-contained true SyncTool/SyncTool.csproj
73+
74+
- uses: actions/upload-artifact@v4
75+
with:
76+
name: SyncTool_linux-arm64
77+
path: SyncTool/bin/Release/net8.0/linux-arm64/publish

SyncTool/Client/SyncOptions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ async Task RemoveRedundantFolder(List<SyncFolderPathInfo> syncFolderPathInfoList
299299
return;
300300
}
301301

302+
if (!Directory.Exists(folder))
303+
{
304+
// 如果文件夹不存在了,可能是之前删除了,不再继续
305+
// 什么情况可能导致文件夹不存在?如有这样的路径 A\B\C 结构
306+
// 之前进入到 A\B 时,将 B 删除了,那么 A\B\C 就会不存在
307+
continue;
308+
}
309+
302310
if (Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories).Any())
303311
{
304312
// 如果存在文件,则不是空文件夹,不能删除
@@ -340,6 +348,13 @@ async Task RemoveRedundantFolder(List<SyncFolderPathInfo> syncFolderPathInfoList
340348
}
341349
}
342350
}
351+
352+
foreach (var syncFolderPathInfo in syncFolderPathInfoList)
353+
{
354+
var folderPath = Path.Join(syncFolder, syncFolderPathInfo.RelativePath);
355+
// 重新创建,防止误删空文件夹
356+
Directory.CreateDirectory(folderPath);
357+
}
343358
}
344359

345360
async Task<string> DownloadFile(SyncFileInfo remoteSyncFileInfo)

0 commit comments

Comments
 (0)