Skip to content

Commit 7d6510c

Browse files
committed
修改逻辑
1 parent 15634bc commit 7d6510c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CnBlogPublishTool.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
99
ProjectSection(SolutionItems) = preProject
1010
shell\deploy.bat = shell\deploy.bat
1111
shell\publish.bat = shell\publish.bat
12+
README.md = README.md
1213
EndProjectSection
1314
EndProject
1415
Global

CnBlogPublishTool/CnBlogPublishTool.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<ItemGroup>
1010
<PackageReference Include="MetaWeblogClient.Core" Version="1.1.0" />
1111
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
12+
<PackageReference Include="Polly" Version="6.0.1" />
1213
</ItemGroup>
1314

1415
<ItemGroup>

CnBlogPublishTool/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ static void SetConfig()
7575
Convert.ToBase64String(TeaHelper.Encrypt(Encoding.UTF8.GetBytes(pwd), _teaKey)));
7676

7777
File.WriteAllText(ConfigFilePath,JsonConvert.SerializeObject(_connInfo));
78+
79+
_connInfo.Password = pwd;
80+
81+
ImageUploader.Init(_connInfo);
7882
}
7983

8084
static void ProcessFile(string[] args)
@@ -109,7 +113,10 @@ static void ProcessFile(string[] args)
109113
if (File.Exists(imgPhyPath))
110114
{
111115
var imgUrl = ImageUploader.Upload(imgPhyPath);
112-
ReplaceDic.Add(img, imgUrl);
116+
if (!ReplaceDic.ContainsKey(img))
117+
{
118+
ReplaceDic.Add(img, imgUrl);
119+
}
113120
Console.WriteLine($"{img} 上传成功. {imgUrl}");
114121
}
115122
else
@@ -130,7 +137,7 @@ static void ProcessFile(string[] args)
130137
_fileContent = _fileContent.Replace(key, ReplaceDic[key]);
131138
}
132139

133-
string newFileName = _filePath.Substring(0, _filePath.LastIndexOf('.')) + "-cnblog-" +
140+
string newFileName = _filePath.Substring(0, _filePath.LastIndexOf('.')) + "-cnblog" +
134141
new FileInfo(_filePath).Extension;
135142
File.WriteAllText(newFileName, _fileContent, TxtFileEncoder.GetEncoding(_filePath));
136143

0 commit comments

Comments
 (0)