Skip to content

Commit

Permalink
uploader.py: simplify clear_locks by using rglob (commaai#32974)
Browse files Browse the repository at this point in the history
simplify clear_locks
  • Loading branch information
deanlee authored Aug 2, 2024
1 parent 2cd9975 commit cafca4f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions system/loggerd/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from openpilot.system.hardware.hw import Paths
from openpilot.system.loggerd.xattr_cache import getxattr, setxattr
from openpilot.common.swaglog import cloudlog
from pathlib import Path

NetworkType = log.DeviceState.NetworkType
UPLOAD_ATTR_NAME = 'user.upload'
Expand Down Expand Up @@ -61,12 +62,9 @@ def listdir_by_creation(d: str) -> list[str]:
return []

def clear_locks(root: str) -> None:
for logdir in os.listdir(root):
path = os.path.join(root, logdir)
for lock_file in Path(root).rglob('*.lock'):
try:
for fname in os.listdir(path):
if fname.endswith(".lock"):
os.unlink(os.path.join(path, fname))
lock_file.unlink()
except OSError:
cloudlog.exception("clear_locks failed")

Expand Down

0 comments on commit cafca4f

Please sign in to comment.