Skip to content

Commit

Permalink
Do not allow application updates to be cancelled.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstrouse committed Feb 2, 2024
1 parent 8bdfd21 commit 234f9d9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
12 changes: 7 additions & 5 deletions GitOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,11 @@ void GitUpdater::loop() {
}
else if(this->status == GIT_UPDATE_CANCELLING) {
Serial.println("Cancelling update process..........");
this->status = GIT_UPDATE_CANCELLED;
this->emitUpdateCheck();
this->cancelled = true;
if(!this->lockFS) {
this->status = GIT_UPDATE_CANCELLED;
this->cancelled = true;
this->emitUpdateCheck();
}
}
}
void GitUpdater::checkForUpdate() {
Expand Down Expand Up @@ -382,7 +384,7 @@ bool GitUpdater::beginUpdate(const char *version) {
this->emitUpdateCheck();
this->setFirmwareFile();
this->partition = U_FLASH;
this->cancelled = false;
this->lockFS = this->cancelled = false;
this->error = 0;
this->error = this->downloadFile();
if(this->error == 0 && !this->cancelled) {
Expand Down Expand Up @@ -457,7 +459,7 @@ int8_t GitUpdater::downloadFile() {
while(https.connected() && (len > 0 || len == -1) && total < len) {
size_t size = stream->available();
if(size) {
if(this->cancelled) {
if(this->cancelled && !this->lockFS) {
Update.abort();
https.end();
free(buff);
Expand Down
1 change: 1 addition & 0 deletions GitOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class GitRepo {
class GitUpdater {
public:
bool lockFS = false;
bool canCancel = true;
uint8_t status = 0;
uint32_t lastCheck = 0;
bool updateAvailable = false;
Expand Down
Binary file modified SomfyController.ino.esp32.bin
Binary file not shown.
Binary file modified SomfyController.ino.esp32s3.bin
Binary file not shown.
Binary file modified SomfyController.littlefs.bin
Binary file not shown.
8 changes: 5 additions & 3 deletions Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,9 +1090,11 @@ void Web::begin() {
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
DynamicJsonDocument sdoc(512);
JsonObject sobj = sdoc.to<JsonObject>();
git.status = GIT_UPDATE_CANCELLING;
git.toJSON(sobj);
git.cancelled = true;
if(!git.lockFS) {
git.status = GIT_UPDATE_CANCELLING;
git.toJSON(sobj);
git.cancelled = true;
}
serializeJson(sdoc, g_content);
server.send(200, _encoding_json, g_content);
});
Expand Down
8 changes: 4 additions & 4 deletions data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="main.css?v=2.3.2b" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.3.2b" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.3.2b" type="text/css" />
<link rel="stylesheet" href="main.css?v=2.3.2c" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.3.2c" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.3.2c" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<script type="text/javascript" src="index.js?v=2.3.2b"></script>
<script type="text/javascript" src="index.js?v=2.3.2c"></script>
</head>
<body>
<div id="divContainer" class="container main" data-auth="false">
Expand Down
5 changes: 4 additions & 1 deletion data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4277,6 +4277,9 @@ class Firmware {
// Update the status on the client that started the install.
if (pct >= 100 && prog.part === 100) git.remove();
else {
if (prog.part === 100) {
document.getElementById('btnCancelUpdate').style.display = 'none';
}
let p = prog.part === 100 ? document.getElementById('progApplicationDownload') : document.getElementById('progFirmwareDownload');
if (p) {
p.style.setProperty('--progress', `${pct}%`);
Expand Down Expand Up @@ -4306,7 +4309,7 @@ class Firmware {
else {
general.reloadApp = true;
// Change the display and allow the percentage to be shown when the socket emits the progress.
let html = `<div>Installing ${ver.name}</div><div style="font-size:.7em;margin-top:4px;">Please wait as the files are downloaded and installed.</div>`;
let html = `<div>Installing ${ver.name}</div><div style="font-size:.7em;margin-top:4px;">Please wait as the files are downloaded and installed. Once the application update process starts you may no longer cancel the update as this will corrupt the downloaded files.</div>`;
html += `<div class="progress-bar" id="progFirmwareDownload" style="--progress:0%;margin-top:10px;text-align:center;"></div>`;
html += `<label for="progFirmwareDownload" style="font-size:10pt;">Firmware Install Progress</label>`;
html += `<div class="progress-bar" id="progApplicationDownload" style="--progress:0%;margin-top:10px;text-align:center;"></div>`;
Expand Down

0 comments on commit 234f9d9

Please sign in to comment.