From 6fa2220cc067bac7992272c48a19987d78aa3b1a Mon Sep 17 00:00:00 2001 From: Yehuda Davis Date: Fri, 25 Aug 2023 11:18:03 -0400 Subject: [PATCH] fix bug when there is no existing chromedriver exe --- undetected_chromedriver/patcher.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/undetected_chromedriver/patcher.py b/undetected_chromedriver/patcher.py index 1b5409d..af5aee1 100644 --- a/undetected_chromedriver/patcher.py +++ b/undetected_chromedriver/patcher.py @@ -133,12 +133,13 @@ class Patcher(object): if self.user_multi_procs: with Lock(): files = list(p.rglob("*chromedriver*")) - most_recent = max(files, key=lambda f: f.stat().st_mtime) - files.remove(most_recent) - list(map(lambda f: f.unlink(), files)) - if self.is_binary_patched(most_recent): - self.executable_path = str(most_recent) - return True + if files: + most_recent = max(files, key=lambda f: f.stat().st_mtime) + files.remove(most_recent) + list(map(lambda f: f.unlink(), files)) + if self.is_binary_patched(most_recent): + self.executable_path = str(most_recent) + return True if executable_path: self.executable_path = executable_path