Import: Skip unchanged tasks
- Re-importing the same file will now lead to no task changes. Previously the "modified:" attribute got updated each time an already imported file was imported again.
This commit is contained in:
@@ -112,19 +112,32 @@ int CmdImport::import (std::vector <std::string>& lines)
|
|||||||
Task task (object);
|
Task task (object);
|
||||||
|
|
||||||
// Check whether the imported task is new or a modified existing task.
|
// Check whether the imported task is new or a modified existing task.
|
||||||
Task dummy;
|
Task before;
|
||||||
if (context.tdb2.get (task.get ("uuid"), dummy))
|
if (context.tdb2.get (task.get ("uuid"), before))
|
||||||
{
|
{
|
||||||
context.tdb2.modify (task);
|
// "modified:" is automatically set to the current time when a task is
|
||||||
std::cout << " mod ";
|
// changed. If the imported task has a modification timestamp we need
|
||||||
|
// to ignore it in taskDiff() in order to check for meaningful
|
||||||
|
// differences. Setting it to the previous value achieves just that.
|
||||||
|
task.set ("modified", before.get ("modified"));
|
||||||
|
if (taskDiff (before, task))
|
||||||
|
{
|
||||||
|
context.tdb2.modify (task);
|
||||||
|
std::cout << " mod ";
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << " skip ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.tdb2.add (task);
|
context.tdb2.add (task);
|
||||||
std::cout << " add ";
|
std::cout << " add ";
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
++count;
|
|
||||||
std::cout << task.get ("uuid")
|
std::cout << task.get ("uuid")
|
||||||
<< " "
|
<< " "
|
||||||
<< task.get ("description")
|
<< task.get ("description")
|
||||||
|
|||||||
Reference in New Issue
Block a user