Skip to content

Commit

Permalink
fix(v3.6.x): otaclient.persist_file_handling: fix incorrect new swapf…
Browse files Browse the repository at this point in the history
…ile fpath (#281)

This PR fixes an issue when creating new swapfile during persist_file_handling. The new swapfile's fpath is incorrect, resulting in new swapfile not being created.
  • Loading branch information
Bodong-Yang authored Apr 2, 2024
1 parent bc83e31 commit 1422677
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions otaclient/app/ota_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,19 @@ def _process_persistents(self):

# NOTE(20240220): fast fix for handling swapfile
if str(_per_fpath) in ["/swapfile", "/swap.img"]:
_new_swapfile = standby_slot_mp / _per_fpath
# NOTE: here we probe the current running system's swapfile at /.
if not _per_fpath.is_file():
continue

_new_swapfile = standby_slot_mp / _per_fpath.relative_to("/")
try:
_swapfile_size = get_file_size(_per_fpath, units="MiB")
assert _swapfile_size is not None, f"{_per_fpath} doesn't exist"
create_swapfile(_new_swapfile, _swapfile_size)
except Exception as e:
logger.warning(f"failed to create {_per_fpath}, skip: {e!r}")
logger.warning(
f"failed to create swapfile {_per_fpath} to standby slot, skip: {e!r}"
)
continue

if (
Expand Down

0 comments on commit 1422677

Please sign in to comment.