From 2a621a43673671c24952cee7b38524b98d5ad886 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 8 Aug 2015 00:49:54 -0400 Subject: [PATCH] TW-1636: UUID with numeric-only first segment is not parsed properly - Switched Nibbler::getUUID to Nibbler::getPartialUUID, which caused partial UUID mathcing to fail sometimes. - Changed precedence to search for UUID before ID, which solves the numeric UUID problem. --- src/DOM.cpp | 13 ++++++------- src/TDB2.cpp | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/DOM.cpp b/src/DOM.cpp index 5a2058567..944001a0c 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -255,24 +255,23 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value) std::string uuid; bool proceed = false; - if (n.getInt (id) && n.depleted ()) + if (n.getPartialUUID (uuid) && n.depleted ()) { - if (id == task.id) + if (uuid == task.get ("uuid")) ref = task; else - context.tdb2.get (id, ref); + context.tdb2.get (uuid, ref); proceed = true; } else { - n.restore (); - if (n.getUUID (uuid) && n.depleted ()) + if (n.getInt (id) && n.depleted ()) { - if (uuid == task.get ("uuid")) + if (id == task.id) ref = task; else - context.tdb2.get (uuid, ref); + context.tdb2.get (id, ref); proceed = true; } diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 4e6d1c705..61246a027 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -115,7 +115,7 @@ bool TF2::get (int id, Task& task) } //////////////////////////////////////////////////////////////////////////////// -// Locate task by uuid. +// Locate task by uuid, which may be a partial UUID. bool TF2::get (const std::string& uuid, Task& task) { if (! _loaded_tasks) @@ -123,7 +123,7 @@ bool TF2::get (const std::string& uuid, Task& task) for (auto& i : _tasks) { - if (i.get ("uuid") == uuid) + if (closeEnough (i.get ("uuid"), uuid, uuid.length ())) { task = i; return true;