mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TDB2
- Verifies that a UUID is not already found in the data. This prevents erroneous double-import. Or triple...
This commit is contained in:
parent
d7ba2b2b62
commit
501953a6da
2 changed files with 18 additions and 0 deletions
15
src/TDB2.cpp
15
src/TDB2.cpp
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue