Skip to content

Commit

Permalink
otaclient: use get_file_size helper instead of detect_swapfile_size
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Mar 4, 2024
1 parent 42052bf commit 5336484
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions otaclient/app/ota_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
)
from . import log_setting

from otaclient._utils.linux import create_swapfile, detect_swapfile_size
from otaclient._utils import get_file_size
from otaclient._utils.linux import create_swapfile

try:
from otaclient import __version__ # type: ignore
Expand Down Expand Up @@ -312,11 +313,11 @@ def _process_persistents(self):
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
_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}: {e!r}")
logger.warning(f"failed to create {_per_fpath}, skip: {e!r}")
continue

if (
Expand Down

0 comments on commit 5336484

Please sign in to comment.