Skip to content

Commit

Permalink
fix same kapp always overwriting in flash
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeubas committed Dec 3, 2024
1 parent d2a99d1 commit b7bafb1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/krux/pages/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,20 @@ def sd_load_app(self): # pylint: disable=R1710
import os
from krux.settings import FLASH_PATH

Check warning on line 144 in src/krux/pages/tools.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/tools.py#L143-L144

Added lines #L143 - L144 were not covered by tests

found_in_flash_vfs = False
path_prefix = "/%s/" % FLASH_PATH
for file in os.listdir(path_prefix):
if file.endswith(MPY_FILE_EXTENSION):

Check warning on line 148 in src/krux/pages/tools.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/tools.py#L146-L148

Added lines #L146 - L148 were not covered by tests
# Check if file is the same from SD
# Only remove .mpy different from what was loaded from SD
if (

Check warning on line 150 in src/krux/pages/tools.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/tools.py#L150

Added line #L150 was not covered by tests
hashlib.sha256(open(path_prefix + file, "rb").read()).digest()
!= data_hash
):
os.remove(path_prefix + file)

Check warning on line 154 in src/krux/pages/tools.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/tools.py#L154

Added line #L154 was not covered by tests

# Copy kapp + sig from SD to flash VFS
# Copy kapp + sig from SD to flash VFS if not found
# sig file allows the check and execution of the kapp at startup for opsec
kapp_filename = "kapp"
if not found_in_flash_vfs:
if not any(kapp_filename in file for file in os.listdir(path_prefix)):
with open(

Check warning on line 160 in src/krux/pages/tools.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/tools.py#L158-L160

Added lines #L158 - L160 were not covered by tests
path_prefix + kapp_filename + MPY_FILE_EXTENSION, "wb"
) as kapp_file:
Expand Down

0 comments on commit b7bafb1

Please sign in to comment.