- Verifies that a UUID is not already found in the data.  This prevents
  erroneous double-import.  Or triple...
This commit is contained in:
Paul Beckingham 2011-08-21 22:37:02 -04:00
parent d7ba2b2b62
commit 501953a6da
2 changed files with 18 additions and 0 deletions

View file

@ -385,6 +385,11 @@ void TDB2::add (const Task& task)
{
// std::cout << "# TDB2::add\n";
// If the tasks are loaded, then verify that this uuid is not already in
// the file.
if (!verifyUniqueUUID (task.get ("uuid")))
throw format ("Cannot add task because the uuid '{1}' is not unique.", task.get ("uuid"));
std::string status = task.get ("status");
if (status == "completed" ||
status == "deleted")
@ -485,6 +490,16 @@ int TDB2::next_id ()
return _id++;
}
////////////////////////////////////////////////////////////////////////////////
bool TDB2::verifyUniqueUUID (const std::string& uuid)
{
if (pending.id (uuid) != 0 ||
completed.id (uuid) != 0)
return false;
return true;
}
////////////////////////////////////////////////////////////////////////////////
//
// File RW State Tasks + - ~ lines + - Bytes