From 2a8d103dc68bdf1dd8e0beae1a339553341155b8 Mon Sep 17 00:00:00 2001 From: tedder Date: Sat, 22 Dec 2018 14:47:52 -0800 Subject: [PATCH] handle missing uuid at sha time Even if a user doesn't have a uuid at startup, they might enable tracking later and .. then a uuid isn't created until the next startup. For this reason and others, we shouldn't pass None to sha.update. Also, by adding a 'uuid missing' string to the log post, we can now track how many instances are missing a uuid for some reason. (though these may show now as a uuid of 'None'). --- src/octoprint/plugins/tracking/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py index cf1b79ab5..73a57dd0f 100644 --- a/src/octoprint/plugins/tracking/__init__.py +++ b/src/octoprint/plugins/tracking/__init__.py @@ -160,7 +160,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, self._logger.info("Initialized anonymous tracking") def _init_id(self): - if self._settings.get_boolean([b"enabled"]) and not self._settings.get([b"unique_id"]): + if not self._settings.get([b"unique_id"]): import uuid self._settings.set([b"unique_id"], str(uuid.uuid4())) self._settings.save() @@ -290,7 +290,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, sha = hashlib.sha1() sha.update(payload.get("path")) - sha.update(self._settings.get([b"unique_id"])) + sha.update(self._settings.get([b"unique_id"]) or '') track_event = None args = dict(origin=payload.get(b"origin"), file=sha.hexdigest()) @@ -369,7 +369,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, return server = self._settings.get([b"server"]) - url = server.format(id=self._settings.get([b"unique_id"]), event=event) + url = server.format(id=self._settings.get([b"unique_id"]) or 'no_uuid', event=event) # Don't print the URL or UUID! That would expose the UUID in forums/tickets # if pasted. It's okay for the user to know their uuid, but it shouldn't be shared.