MCPcopy Create free account
hub / github.com/Universal-Team/Universal-Updater / QueueHandle

Method QueueHandle

source/utils/queueSystem.cpp:109–414  ·  view source on GitHub ↗

The whole handle. */

Source from the content-addressed store, hash-verified

107 The whole handle.
108*/
109void QueueSystem::QueueHandle() {
110 while(QueueRuns) {
111 Result ret = NONE; // No Error as of yet.
112
113 for(int i = QueueSystem::LastElement; ret == NONE && i < queueEntries[0]->total && !QueueSystem::CancelCallback; i++) {
114 queueEntries[0]->current++;
115
116 std::string type = "";
117
118 if (queueEntries[0]->obj[i].contains("type") && queueEntries[0]->obj[i]["type"].is_string()) {
119 type = queueEntries[0]->obj[i]["type"];
120
121 } else {
122 ret = SYNTAX_ERROR;
123 }
124
125 /* Deleting a file. */
126 if (type == "deleteFile") {
127 bool missing = false;
128 std::string file = "";
129 queueEntries[0]->status = QueueStatus::Deleting;
130
131 if (queueEntries[0]->obj[i].contains("file") && queueEntries[0]->obj[i]["file"].is_string()) {
132 file = queueEntries[0]->obj[i]["file"];
133 } else missing = true;
134
135 if (!missing) ret = ScriptUtils::removeFile(file, "");
136 else ret = SYNTAX_ERROR;
137
138 /* Downloading from a URL. */
139 } else if (type == "downloadFile") {
140 bool missing = false;
141 std::string file = "", output = "";
142
143 queueEntries[0]->status = QueueStatus::Downloading;
144
145 if (queueEntries[0]->obj[i].contains("file") && queueEntries[0]->obj[i]["file"].is_string()) {
146 file = queueEntries[0]->obj[i]["file"];
147 } else missing = true;
148
149 if (queueEntries[0]->obj[i].contains("output") && queueEntries[0]->obj[i]["output"].is_string()) {
150 output = queueEntries[0]->obj[i]["output"];
151 } else missing = true;
152
153 if (!missing) ret = ScriptUtils::downloadFile(file, output, "", false);
154 else ret = SYNTAX_ERROR;
155
156 /* Download from a GitHub Release. */
157 } else if (type == "downloadRelease") {
158 bool missing = false, includePrereleases = false;
159 std::string repo = "", file = "", output = "";
160
161 queueEntries[0]->status = QueueStatus::Downloading;
162
163 if (queueEntries[0]->obj[i].contains("repo") && queueEntries[0]->obj[i]["repo"].is_string()) {
164 repo = queueEntries[0]->obj[i]["repo"];
165 } else missing = true;
166

Callers

nothing calls this directly

Calls 8

makeDirsFunction · 0.85
getFunction · 0.85
removeDirRecursiveFunction · 0.85
savedPromptMethod · 0.80
SetUpdatedMethod · 0.80
emptyMethod · 0.45
promptMethod · 0.45
SetInstalledMethod · 0.45

Tested by

no test coverage detected