Skip to content

Commit

Permalink
implement fast fix for handling swapfile in persist handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Mar 4, 2024
1 parent 9a6847b commit a34580b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions otaclient/app/ota_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
)
from . import log_setting

from otaclient._utils.linux import create_swapfile, detect_swapfile_size

try:
from otaclient import __version__ # type: ignore
except ImportError:
Expand Down Expand Up @@ -304,13 +306,23 @@ def _process_persistents(self):
for _perinf in self._otameta.iter_metafile(
ota_metadata.MetafilesV1.PERSISTENT_FNAME
):
_perinf_path = Path(_perinf.path)
_per_fpath = Path(_perinf.path)

# NOTE(20240220): fast fix for handling swapfile
if str(_per_fpath) in ["/swapfile", "/swap.img"]:
_new_swapfile = standby_slot_mp / _per_fpath
try:
_swapfile_size = detect_swapfile_size(_per_fpath) # in MiB
assert _swapfile_size is not None
create_swapfile(_new_swapfile, _swapfile_size)
except Exception as e:
logger.warning(f"failed to create {_per_fpath}: {e!r}")
continue

if (
_perinf_path.is_file()
or _perinf_path.is_dir()
or _perinf_path.is_symlink()
_per_fpath.is_file() or _per_fpath.is_dir() or _per_fpath.is_symlink()
): # NOTE: not equivalent to perinf.path.exists()
_copy_tree.copy_with_parents(_perinf_path, standby_slot_mp)
_copy_tree.copy_with_parents(_per_fpath, standby_slot_mp)

def _execute_update(
self,
Expand Down

0 comments on commit a34580b

Please sign in to comment.