Skip to content

Commit 34d79be

Browse files
committed
Hotfix 4
1 parent 8944a08 commit 34d79be

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Uploader/Program.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,29 @@ static int Main(string host, string name, string password)
4444
using var stream = _.OpenRead();
4545
var md5 = stream.ComputeMD5();
4646

47-
// 文件名格式:Minecraft-Mod-Language-ModPack-[version]-[md5-hash].zip
47+
// 文件名格式:Minecraft-Mod-Language-Modpack-[dashed-version]-[md5-hash].zip
48+
// 如:Minecraft-Mod-Language-Modpack-1-12-2-0000000000000000.zip
4849
// hash的对象是文件内容,不包括文件名(当然)
4950
// hash应该是全大写
50-
var fileName = _.Name.Replace("Package", "Modpack"); // 历史遗留问题
51+
52+
var fileExtensionName = _.Extension; // 带点名称,应当为 ".zip"
53+
var fileName = _.Name[0..^fileExtensionName.Length]
54+
.Replace("Package", "Modpack")
55+
.Replace('.', '-'); // 历史遗留问题
5156

5257
// 选择性地加上该文件的md5值,以便生成patch
53-
var tweakedName = fileName.Insert(fileName.LastIndexOf('.'), "-" + md5);
58+
var tweakedName = fileName + "-" + md5;
59+
60+
var destinationName = $"/var/www/html/files/{fileName + fileExtensionName}";
61+
var tweakedDestinationName = $"/var/www/html/files/{tweakedName + fileExtensionName}";
5462

5563
// 传递不带md5值的最新版本;会覆写已有文件
56-
scpClient.Upload(_.OpenRead(), $"/var/www/html/files/{fileName}");
57-
Log.Information("向远程服务器写入文件:{0}", $"/var/www/html/files/{fileName}");
64+
scpClient.Upload(_.OpenRead(), destinationName);
65+
Log.Information("向远程服务器写入文件:{0}", destinationName);
5866

5967
//// 传递带md5值的历史版本,一般不会覆写已有文件
60-
//scpClient.Upload(_.OpenRead(), $"/var/www/html/files/history/{tweakedName}");
61-
//Log.Information("向远程服务器写入文件:{0}", $"/var/www/html/files/history/{tweakedName}");
68+
//scpClient.Upload(_.OpenRead(), tweakedDestinationName);
69+
//Log.Information("向远程服务器写入文件:{0}", tweakedDestinationName);
6270
});
6371

6472
// 临时操作 在使用旧md5校验的程序弃用以后需要删除

0 commit comments

Comments
 (0)