mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-11 04:12:07 +08:00
don't upload crash logs from forks (#30203)
* don't upload crash logs from forks * fix old-commit-hash: 1abea5a2596f36eec56d52c9d3a900b7396cf262
This commit is contained in:
+4
-2
@@ -42,11 +42,11 @@ def set_tag(key: str, value: str) -> None:
|
||||
sentry_sdk.set_tag(key, value)
|
||||
|
||||
|
||||
def init(project: SentryProject) -> None:
|
||||
def init(project: SentryProject) -> bool:
|
||||
# forks like to mess with this, so double check
|
||||
comma_remote = is_comma_remote() and "commaai" in get_origin(default="")
|
||||
if not comma_remote or not is_registered_device() or PC:
|
||||
return
|
||||
return False
|
||||
|
||||
env = "release" if is_tested_branch() else "master"
|
||||
dongle_id = Params().get("DongleId", encoding='utf-8')
|
||||
@@ -73,3 +73,5 @@ def init(project: SentryProject) -> None:
|
||||
|
||||
if project == SentryProject.SELFDRIVE:
|
||||
sentry_sdk.Hub.current.start_session()
|
||||
|
||||
return True
|
||||
|
||||
+18
-13
@@ -46,19 +46,16 @@ def get_apport_stacktrace(fn):
|
||||
|
||||
|
||||
def get_tombstones():
|
||||
"""Returns list of (filename, ctime) for all tombstones in /data/tombstones
|
||||
and apport crashlogs in /var/crash"""
|
||||
"""Returns list of (filename, ctime) for all crashlogs"""
|
||||
files = []
|
||||
for folder in [TOMBSTONE_DIR, APPORT_DIR]:
|
||||
if os.path.exists(folder):
|
||||
with os.scandir(folder) as d:
|
||||
|
||||
# Loop over first 1000 directory entries
|
||||
for _, f in zip(range(1000), d, strict=False):
|
||||
if f.name.startswith("tombstone"):
|
||||
files.append((f.path, int(f.stat().st_ctime)))
|
||||
elif f.name.endswith(".crash") and f.stat().st_mode == 0o100640:
|
||||
files.append((f.path, int(f.stat().st_ctime)))
|
||||
if os.path.exists(APPORT_DIR):
|
||||
with os.scandir(APPORT_DIR) as d:
|
||||
# Loop over first 1000 directory entries
|
||||
for _, f in zip(range(1000), d, strict=False):
|
||||
if f.name.startswith("tombstone"):
|
||||
files.append((f.path, int(f.stat().st_ctime)))
|
||||
elif f.name.endswith(".crash") and f.stat().st_mode == 0o100640:
|
||||
files.append((f.path, int(f.stat().st_ctime)))
|
||||
return files
|
||||
|
||||
|
||||
@@ -143,7 +140,7 @@ def report_tombstone_apport(fn):
|
||||
|
||||
|
||||
def main() -> NoReturn:
|
||||
sentry.init(sentry.SentryProject.SELFDRIVE_NATIVE)
|
||||
should_report = sentry.init(sentry.SentryProject.SELFDRIVE_NATIVE)
|
||||
|
||||
# Clear apport folder on start, otherwise duplicate crashes won't register
|
||||
clear_apport_folder()
|
||||
@@ -153,6 +150,14 @@ def main() -> NoReturn:
|
||||
now_tombstones = set(get_tombstones())
|
||||
|
||||
for fn, _ in (now_tombstones - initial_tombstones):
|
||||
# clear logs if we're not interested in them
|
||||
if not should_report:
|
||||
try:
|
||||
os.remove(fn)
|
||||
except Exception:
|
||||
pass
|
||||
continue
|
||||
|
||||
try:
|
||||
cloudlog.info(f"reporting new tombstone {fn}")
|
||||
if fn.endswith(".crash"):
|
||||
|
||||
Reference in New Issue
Block a user