TDB2
- Verifies that a UUID is not already found in the data. This prevents erroneous double-import. Or triple...
This commit is contained in:
15
src/TDB2.cpp
15
src/TDB2.cpp
@@ -385,6 +385,11 @@ void TDB2::add (const Task& task)
|
|||||||
{
|
{
|
||||||
// std::cout << "# TDB2::add\n";
|
// 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");
|
std::string status = task.get ("status");
|
||||||
if (status == "completed" ||
|
if (status == "completed" ||
|
||||||
status == "deleted")
|
status == "deleted")
|
||||||
@@ -485,6 +490,16 @@ int TDB2::next_id ()
|
|||||||
return _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
|
// File RW State Tasks + - ~ lines + - Bytes
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ public:
|
|||||||
void dump ();
|
void dump ();
|
||||||
void dump_file (ViewText&, const std::string&, TF2&);
|
void dump_file (ViewText&, const std::string&, TF2&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool verifyUniqueUUID (const std::string&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TF2 pending;
|
TF2 pending;
|
||||||
TF2 completed;
|
TF2 completed;
|
||||||
|
|||||||
Reference in New Issue
Block a user