fix: dismiss a verified prewrite startup tip during release

This commit is contained in:
阿白叔 committed 2026-11-25 10:26:16 +08:00
1 parent 2722d09b59
commit 6a716052f4
2 files changed
+26 -10

No files matched your search

+12 -4
View File
@@ -1041,13 +1041,13 @@ def finish_owned_idle_session(path, *, stop=None):
if not acquired or stop is not None and stop.is_set(): return False
session, state, identities = _session(path, path.parent)
if 'owned_idle_cleanup' in session: return False
def read(name):
def read(name, *, lines=False):
item = path.with_name(name)
if item.lstat().st_file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT:
raise ValueError('OWNED_CLEANUP_REPARSE_POINT')
with item.open('rb') as stream: data = stream.read(1024*1024+1)
if len(data) > 1024*1024: raise ValueError('OWNED_CLEANUP_RECORD_TOO_LARGE')
return json.loads(data)
return [json.loads(line) for line in data.splitlines()] if lines else json.loads(data)
job = read('request.json')
if not isinstance(job, dict): return False
if (any(job.get(k) != session.get(k) for k in ('operation_id','operation','library','desktop','block'))
@@ -1144,9 +1144,17 @@ def finish_owned_idle_session(path, *, stop=None):
if len(modals) != 1:
return None
with _window_desktop(desktop):
observed = _startup_snapshot(modals[0]['hwnd'], client['pid'])
tip = _tip_target(observed) if orphan_client is not None and modals[0]['title'] == 'Tip of the Day' else None
modal = modals[0]
observed = _startup_snapshot(modal['hwnd'], client['pid'])
tip = _tip_target(observed) if modal['title'] == 'Tip of the Day' else None
if tip is not None:
# A preceding cleanup can leave this same Tip visible; no repeated action.
if any(event.get('pcb_pid') == client['pid'] and
(event.get('stage') == 'startup_close_requested'
or event.get('stage') == 'startup_tip_dismissed'
and event.get('hwnd') == modal['hwnd'])
for event in read('events.jsonl', lines=True)):
return None
return observed, tip.handle, 'tip'
target = _cancel_target(observed)
if target is not None and (orphan_client is not None or target[0] == 'database_load_log'):