mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Task: Bump annotations with duplicate entry values
Since annotations are stored as a map, duplicate entry values lead to data loss (i.e. annotations overriding each other on import). Perhaps the choice of using a map internally should be reconsidered. Closes #1938.
This commit is contained in:
parent
3fed9e9abb
commit
a219bd30cf
1 changed files with 17 additions and 2 deletions
19
src/Task.cpp
19
src/Task.cpp
|
@ -766,8 +766,23 @@ void Task::parseJSON (const json::object* root_obj)
|
||||||
if (! what)
|
if (! what)
|
||||||
throw format ("Annotation is missing a description: {1}", root_obj->dump ());
|
throw format ("Annotation is missing a description: {1}", root_obj->dump ());
|
||||||
|
|
||||||
std::string name = "annotation_" + Datetime (when->_data).toEpochString ();
|
// Extract 64-bit annotation entry value
|
||||||
annos.insert (std::make_pair (name, json::decode (what->_data)));
|
// Time travelers from 2038, we have your back.
|
||||||
|
long long ann_timestamp = (long long) (Datetime (when->_data).toEpoch ());
|
||||||
|
|
||||||
|
std::stringstream name;
|
||||||
|
name << "annotation_" << ann_timestamp;
|
||||||
|
|
||||||
|
// Increment the entry timestamp in case of a conflict. Same
|
||||||
|
// behaviour as CmdAnnotate.
|
||||||
|
while (annos.find(name.str ()) != annos.end ())
|
||||||
|
{
|
||||||
|
name.str (""); // Clear
|
||||||
|
ann_timestamp++;
|
||||||
|
name << "annotation_" << ann_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
annos.insert (std::make_pair (name.str (), json::decode (what->_data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
setAnnotations (annos);
|
setAnnotations (annos);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue