Skip to content

Commit 5eb22df

Browse files
committed
Updated Updater to ignore if files are missing
This is to allow pure deletion of older unneeded files
1 parent f0bb55c commit 5eb22df

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

Updater/main.cc

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
std::fstream logFile;
1414
bool legacyMode = false;
15+
const std::string logPath = "updateLog.txt";
1516

1617
void startPorcess(LPSTR exePath)
1718
{
@@ -39,8 +40,16 @@ void startPorcess(LPSTR exePath)
3940
CloseHandle(pi.hThread);
4041
}
4142

43+
void initLog()
44+
{
45+
logFile.open(logPath, std::ios::out);
46+
logFile.close();
47+
}
48+
4249
void log(std::string tag, std::string message)
4350
{
51+
logFile.open(logPath, std::ios::app);
52+
4453
char buffer[256];
4554
auto timeNow = std::chrono::system_clock::now();
4655
std::time_t now = std::chrono::system_clock::to_time_t(timeNow);
@@ -51,18 +60,17 @@ void log(std::string tag, std::string message)
5160
sprintf_s(buffer, "[%s] - (%s): %s\n", ss.str().c_str(), tag.c_str(), message.c_str());
5261

5362
logFile.write(buffer, strlen(buffer));
63+
logFile.close();
5464
}
5565

5666
int main(int argc, char* argv[])
5767
{
58-
logFile.open("updateLog.txt", std::ios::out);
5968
log("Initialization", "Started");
6069

6170
FreeConsole();
6271
if (argc < 4)
6372
{
6473
log("Arguments", "Not enough arguments");
65-
logFile.close();
6674
return -1;
6775
}
6876

@@ -88,13 +96,11 @@ int main(int argc, char* argv[])
8896
if (!std::filesystem::exists(exPackPath))
8997
{
9098
log("File Checks", "Extracted files do not exist");
91-
logFile.close();
9299
return -1;
93100
}
94101
if (!std::filesystem::exists(fileListPath) && !legacyMode)
95102
{
96103
log("File Checks", "File list does not exist");
97-
logFile.close();
98104
return -1;
99105
}
100106

@@ -138,7 +144,6 @@ int main(int argc, char* argv[])
138144
if (!std::filesystem::remove(installPath + "\\" + file, ec))
139145
{
140146
log("Installation", ("Deletion failed for file: " + file).c_str());
141-
logFile.close();
142147
return -1;
143148
}
144149
log("Installation", (installPath + "\\" + file).c_str());
@@ -159,8 +164,15 @@ int main(int argc, char* argv[])
159164
{
160165
for (std::string file : fileList)
161166
{
162-
std::filesystem::copy(exPackPath + "\\" + file, installPath + "\\" + file);
163-
log("Installation", (exPackPath + "\\" + file + " => " + installPath + "\\" + file).c_str());
167+
if (std::filesystem::exists(exPackPath + "\\" + file))
168+
{
169+
std::filesystem::copy(exPackPath + "\\" + file, installPath + "\\" + file);
170+
log("Installation", (exPackPath + "\\" + file + " => " + installPath + "\\" + file).c_str());
171+
}
172+
else
173+
{
174+
log("Installation", (exPackPath + "\\" + file + " not found, skipping...").c_str());
175+
}
164176
}
165177
}
166178

@@ -176,6 +188,5 @@ int main(int argc, char* argv[])
176188
startPorcess((LPSTR)exePath.c_str());
177189

178190
log("Finalization", "Closing");
179-
logFile.close();
180191
return 0;
181192
}

VexTrack/Properties/PublishProfiles/FolderProfile.pubxml.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
44
-->
55
<Project>
66
<PropertyGroup>
7-
<History>True|2022-04-23T12:49:56.1096228Z;False|2022-04-23T14:48:07.2583983+02:00;True|2021-10-09T18:18:06.7595219+02:00;True|2021-09-25T13:53:45.6469657+02:00;True|2021-09-25T13:50:42.4330328+02:00;True|2021-08-17T17:49:02.0352516+02:00;True|2021-08-17T17:27:33.8575315+02:00;True|2021-08-17T17:06:31.6865042+02:00;True|2021-08-16T20:32:38.6170493+02:00;True|2021-08-16T19:15:47.4487778+02:00;True|2021-08-16T18:57:52.1937506+02:00;True|2021-08-16T16:55:39.1361001+02:00;True|2021-08-16T16:50:48.1196364+02:00;True|2021-08-16T15:46:13.5753068+02:00;True|2021-08-16T15:42:57.6287483+02:00;True|2021-08-16T15:35:10.4759874+02:00;True|2021-08-16T15:14:29.1127093+02:00;True|2021-08-16T15:13:07.5085065+02:00;True|2021-08-16T14:36:12.2446455+02:00;True|2021-08-15T16:25:42.6055261+02:00;False|2021-08-15T16:22:23.0774038+02:00;False|2021-08-15T16:21:30.1494638+02:00;False|2021-08-15T16:21:04.2805901+02:00;True|2021-08-13T10:15:54.6725225+02:00;True|2021-08-13T10:10:27.5709767+02:00;True|2021-08-13T09:52:28.8007984+02:00;True|2021-08-13T09:52:12.4970269+02:00;True|2021-08-13T09:50:21.0039011+02:00;True|2021-08-13T09:49:30.7597645+02:00;True|2021-08-12T20:45:39.9964695+02:00;</History>
7+
<History>True|2022-04-23T13:34:10.2940837Z;True|2022-04-23T14:49:56.1096228+02:00;False|2022-04-23T14:48:07.2583983+02:00;True|2021-10-09T18:18:06.7595219+02:00;True|2021-09-25T13:53:45.6469657+02:00;True|2021-09-25T13:50:42.4330328+02:00;True|2021-08-17T17:49:02.0352516+02:00;True|2021-08-17T17:27:33.8575315+02:00;True|2021-08-17T17:06:31.6865042+02:00;True|2021-08-16T20:32:38.6170493+02:00;True|2021-08-16T19:15:47.4487778+02:00;True|2021-08-16T18:57:52.1937506+02:00;True|2021-08-16T16:55:39.1361001+02:00;True|2021-08-16T16:50:48.1196364+02:00;True|2021-08-16T15:46:13.5753068+02:00;True|2021-08-16T15:42:57.6287483+02:00;True|2021-08-16T15:35:10.4759874+02:00;True|2021-08-16T15:14:29.1127093+02:00;True|2021-08-16T15:13:07.5085065+02:00;True|2021-08-16T14:36:12.2446455+02:00;True|2021-08-15T16:25:42.6055261+02:00;False|2021-08-15T16:22:23.0774038+02:00;False|2021-08-15T16:21:30.1494638+02:00;False|2021-08-15T16:21:04.2805901+02:00;True|2021-08-13T10:15:54.6725225+02:00;True|2021-08-13T10:10:27.5709767+02:00;True|2021-08-13T09:52:28.8007984+02:00;True|2021-08-13T09:52:12.4970269+02:00;True|2021-08-13T09:50:21.0039011+02:00;True|2021-08-13T09:49:30.7597645+02:00;True|2021-08-12T20:45:39.9964695+02:00;</History>
88
</PropertyGroup>
99
</Project>

0 commit comments

Comments
 (0)