From e7ee7a336975b049d4680958c7c42099d0982325 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Fri, 28 Dec 2018 18:19:32 -0600 Subject: [PATCH] check for missing entity before other checks --- wakatime/heartbeat.py | 6 +++--- wakatime/utils.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wakatime/heartbeat.py b/wakatime/heartbeat.py index bfb6040..eae1ebc 100644 --- a/wakatime/heartbeat.py +++ b/wakatime/heartbeat.py @@ -249,15 +249,15 @@ class Heartbeat(object): if self.type != 'file': return + if not self.entity: + return + if not is_win: return if self._file_exists(): return - if not self.entity: - return - self.args.local_file = self._to_unc_path(self.entity) def _to_unc_path(self, filepath): diff --git a/wakatime/utils.py b/wakatime/utils.py index ba78bc0..a2d7b07 100644 --- a/wakatime/utils.py +++ b/wakatime/utils.py @@ -81,7 +81,8 @@ def format_file_path(filepath): is_windows_network_mount = WINDOWS_NETWORK_MOUNT_PATTERN.match(filepath) filepath = os.path.realpath(os.path.abspath(filepath)) filepath = re.sub(BACKSLASH_REPLACE_PATTERN, '/', filepath) - if WINDOWS_DRIVE_PATTERN.match(filepath): + is_windows_drive = WINDOWS_DRIVE_PATTERN.match(filepath) + if is_windows_drive: filepath = filepath.capitalize() if is_windows_network_mount: # Add back a / to the front, since the previous modifications