Skip to content

Commit

Permalink
Bug: 修复了更新器替换文件时路径写错导致找不到的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shc0743 committed Sep 16, 2024
1 parent 251802a commit 572b2d4
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 51 deletions.
Binary file modified .vs/MyPN532/v17/.suo
Binary file not shown.
78 changes: 30 additions & 48 deletions .vs/MyPN532/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@
"Version": 1,
"WorkspaceRootPath": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{C0AE2D88-5D00-4B90-BCE0-80EB6F9C1993}|PN532_libnfc_Host\\PN532_libnfc_Host.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\better-mfoc.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{C0AE2D88-5D00-4B90-BCE0-80EB6F9C1993}|PN532_libnfc_Host\\PN532_libnfc_Host.vcxproj|solutionrelative:PN532_libnfc_Host\\better-mfoc.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server-ws.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|solutionrelative:MyPN532\\server-ws.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\updater.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|solutionrelative:MyPN532\\updater.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|solutionrelative:MyPN532\\server.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|solutionrelative:MyPN532\\server.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{C0AE2D88-5D00-4B90-BCE0-80EB6F9C1993}|PN532_libnfc_Host\\PN532_libnfc_Host.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\better-mfoc.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{C0AE2D88-5D00-4B90-BCE0-80EB6F9C1993}|PN532_libnfc_Host\\PN532_libnfc_Host.vcxproj|solutionrelative:PN532_libnfc_Host\\better-mfoc.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server-ws.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{BD55E21F-4F64-418A-BC43-3B2762B00779}|MyPN532\\MyPN532.vcxproj|solutionrelative:MyPN532\\server-ws.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{C0AE2D88-5D00-4B90-BCE0-80EB6F9C1993}|PN532_libnfc_Host\\PN532_libnfc_Host.vcxproj|D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\mfclassic.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{C0AE2D88-5D00-4B90-BCE0-80EB6F9C1993}|PN532_libnfc_Host\\PN532_libnfc_Host.vcxproj|solutionrelative:PN532_libnfc_Host\\mfclassic.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
Expand All @@ -38,7 +34,7 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 9,
"SelectedChildIndex": 5,
"Children": [
{
"$type": "Bookmark",
Expand All @@ -62,72 +58,58 @@
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 0,
"Title": "updater.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\updater.cpp",
"RelativeDocumentMoniker": "MyPN532\\updater.cpp",
"ToolTip": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\updater.cpp",
"RelativeToolTip": "MyPN532\\updater.cpp",
"ViewState": "AQIAABwAAAAAAAAAAAAywB4AAAAkAAAA",
"ViewState": "AQIAAMAAAAAAAAAAAAAQwMgAAAAtAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-09-16T16:55:10.815Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 2,
"Title": "better-mfoc.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\better-mfoc.cpp",
"RelativeDocumentMoniker": "PN532_libnfc_Host\\better-mfoc.cpp",
"ToolTip": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\better-mfoc.cpp",
"RelativeToolTip": "PN532_libnfc_Host\\better-mfoc.cpp",
"ViewState": "AQIAAIUEAAAAAAAAAAAiwJwEAAAoAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-08-09T12:26:05.662Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "server-ws.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server-ws.cpp",
"RelativeDocumentMoniker": "MyPN532\\server-ws.cpp",
"ToolTip": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server-ws.cpp",
"RelativeToolTip": "MyPN532\\server-ws.cpp",
"ViewState": "AQIAAAsBAAAAAAAAAAAiwAwBAAATAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-07-20T17:33:46.543Z",
"EditorCaption": ""
"WhenOpened": "2024-07-20T17:33:46.543Z"
},
{
"$type": "Document",
"DocumentIndex": 4,
"DocumentIndex": 1,
"Title": "server.h",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server.h",
"RelativeDocumentMoniker": "MyPN532\\server.h",
"ToolTip": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server.h",
"RelativeToolTip": "MyPN532\\server.h",
"ViewState": "AQIAAC0AAAAAAAAAAAAAADUAAAApAAAA",
"ViewState": "AQIAABsAAAAAAAAAAAAAACoAAAAuAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-09-16T14:04:02.054Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "server.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server.cpp",
"RelativeDocumentMoniker": "MyPN532\\server.cpp",
"ToolTip": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\MyPN532\\server.cpp",
"RelativeToolTip": "MyPN532\\server.cpp",
"ViewState": "AQIAAE8DAAAAAAAAAAAQwFEDAAAOAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-09-16T14:04:44.899Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "better-mfoc.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\better-mfoc.cpp",
"RelativeDocumentMoniker": "PN532_libnfc_Host\\better-mfoc.cpp",
"ToolTip": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\better-mfoc.cpp",
"RelativeToolTip": "PN532_libnfc_Host\\better-mfoc.cpp",
"ViewState": "AQIAAIUEAAAAAAAAAAAiwIkEAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-08-09T12:26:05.662Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"DocumentIndex": 4,
"Title": "mfclassic.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\mfclassic.cpp",
"RelativeDocumentMoniker": "PN532_libnfc_Host\\mfclassic.cpp",
Expand All @@ -139,7 +121,7 @@
},
{
"$type": "Document",
"DocumentIndex": 6,
"DocumentIndex": 5,
"Title": "PN532_libnfc_Host.cpp",
"DocumentMoniker": "D:\\software\\Program\\source\\VSProjects\\MyPN532\\PN532_libnfc_Host\\PN532_libnfc_Host.cpp",
"RelativeDocumentMoniker": "PN532_libnfc_Host\\PN532_libnfc_Host.cpp",
Expand Down
Binary file modified .vs/MyPN532/v17/Solution.VC.db
Binary file not shown.
Binary file modified .vs/MyPN532/v17/fileList.bin
Binary file not shown.
44 changes: 42 additions & 2 deletions MyPN532/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using namespace std;
#include <iostream>
#include "resource.h"
#include "wizard.user.h"
#include <json/json.h>

#pragma comment(lib, "wininet.lib")

Expand Down Expand Up @@ -139,8 +140,10 @@ int UpdaterEntry(CmdLineW& cl) {
OpenMprgWizard(hWiz);
FreeResFile(IDR_BIN_7z_x64, L"BIN", L"x.exe");
MoveFileW(L"../config/userconfig.json", L"../config/U");
FileDeleteTreeW(L"../webroot");
SetCurrentDirectoryW(L"../../");
auto pi = Process.Start_HiddenWindow(GetProgramPathW() + L"/x x -y update.pkg ");
auto pi = Process.Start_HiddenWindow(L"\"" + GetProgramPathW() +
L"/x\" x -y \"" + GetProgramPathW() + L"/update.pkg\" ");
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exitcode = 0;
GetExitCodeProcess(pi.hProcess, &exitcode);
Expand All @@ -150,7 +153,45 @@ int UpdaterEntry(CmdLineW& cl) {
CopyFileW(L"../config/U", L"../config/userconfig.json", FALSE);
DeleteFileW(L"../config/u~g.bak");
MoveFileW(L"../config/U", L"../config/u~g.bak");

do {
Json::Value root;
Json::Reader reader;
std::string filePath = "../config/userconfig.json";
bool fileExists = file_exists(filePath);
if (fileExists) {
if (MyGetFileSizeW(s2ws(filePath)) > static_cast<unsigned long long>(64 * 1024) * 1024) {
// json file > 64MiB
break;
}
std::ifstream file(filePath);
if (!file.is_open()) {
break;
}
std::stringstream buffer;
buffer << file.rdbuf();
file.close();
bool parsingSuccessful = reader.parse(buffer.str(), root);
if (!parsingSuccessful) {
break;
}
}
root.removeMember("updatechecker.pending");

Json::StreamWriterBuilder builder;
builder["indentation"] = " ";
std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
std::ostringstream oss;
writer->write(root, &oss);
std::ofstream outFile(filePath);
if (!outFile.is_open()) {
break;
}
outFile << oss.str();
outFile.close();
} while (0);

DeleteFileW(L"x.exe");
if (exitcode) {
TaskDialog(NULL, NULL, L"MyPN532 Standard Updater",
L"An error has occurred during the update progress.",
Expand All @@ -167,7 +208,6 @@ int UpdaterEntry(CmdLineW& cl) {
TDCBF_YES_BUTTON | TDCBF_CANCEL_BUTTON, TD_INFORMATION_ICON, &l);
if (l == IDYES) Process.StartOnly(L"../../MyPN532_x64.exe");
}
DeleteFileW(L"x.exe");
DeleteFileW(L"update.pkg");
FreeResFile(IDR_BIN_SELF_DELETE, L"BIN", L"d.bat");
Process.StartOnly_HiddenWindow(L"cmd /c d.bat \"" + GetProgramDirW() + L"\"");
Expand Down
Binary file modified bin/MyPN532_x64.exe
Binary file not shown.
Binary file modified bin/MyPN532_x64.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion web/components/UpdateService/UpdateService.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2 class="el-notification__title">正在更新应用程序...</h2>
<div class="el-notification__content">
<p v-text="periodText"></p>
</div>
<ElTooltip placement="bottom" effect="dark" content="暂时隐藏">
<ElTooltip placement="left" effect="dark" content="暂时隐藏">
<ElButton text class="el-icon el-notification__closeBtn" @keydown.capture.stop @click.stop="() => { showBalloon = true; showTask = false; }">
<Close />
</ElButton>
Expand Down

0 comments on commit 572b2d4

Please sign in to comment.