Skip to content

Commit 76c937d

Browse files
committed
Revert Uploader changes
1 parent 5146b44 commit 76c937d

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

src/Uploader/Program.cs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ static int Main(string host, string name, string password)
3131
return -1;
3232
}
3333

34-
35-
3634
// 获取可用的资源包,准备上传
3735
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
3836
var packList = currentDirectory
@@ -53,7 +51,9 @@ static int Main(string host, string name, string password)
5351

5452
var fileExtensionName = _.Extension; // 带点名称,应当为 ".zip"
5553
var fileName = _.Name[0..^fileExtensionName.Length]
56-
.RegulateFileName(); // 无后缀的文件名,应当已修正
54+
.Replace("Package", "Modpack")
55+
.Replace('.', '-') // 历史遗留问题,版本号需要输杠
56+
.Replace("-1-12-2",""); // 历史遗留问题,1.12.2文件没有版本号
5757

5858
// 选择性地加上该文件的md5值,以便生成patch
5959
var tweakedName = fileName + "-" + md5;
@@ -76,33 +76,14 @@ static int Main(string host, string name, string password)
7676
md5List.ToList()
7777
.ForEach(_ =>
7878
{
79-
var fileName = CapitalizeGroup(_.Name); // md5文件名,应当已修正
80-
scpClient.Upload(_.OpenRead(), $"/var/www/html/files/{fileName}");
81-
Log.Information("向远程服务器写入文件:{0}", $"/var/www/html/files/{fileName}");
79+
scpClient.Upload(_.OpenRead(), $"/var/www/html/files/{_.Name}");
80+
Log.Information("向远程服务器写入文件:{0}", $"/var/www/html/files/{_.Name}");
8281
});
8382

8483
Log.Information("资源包传递完毕");
8584
return 0;
8685
}
8786

88-
public static string RegulateFileName(this string fileName) =>
89-
90-
CapitalizeGroup( // 历史遗留问题:全部单词都要大小写
91-
fileName.Replace("Package", "Modpack") // 历史遗留问题:文件名
92-
.Replace('.', '-') // 历史遗留问题:版本号需要输杠
93-
.Replace("-1-12-2", "") // 历史遗留问题:1.12.2文件没有版本号
94-
);
95-
96-
// 将一组字符串的各项大小写,用'-'连接
97-
static string CapitalizeGroup(string text) => string.Join('-',
98-
text.Split('-')
99-
.Select(_ => Capitalize(_)));
100-
101-
// 将一段文本的首字母大写,其余不动
102-
static string Capitalize(string text) => string.Join("",
103-
text[0..0].ToUpper(),
104-
text[1..]);
105-
10687
/// <summary>
10788
/// 计算给定流中全体内容的MD5值。
10889
/// </summary>

0 commit comments

Comments
 (0)