mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 22:47:20 +02:00
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:
parent
9d6067e2fe
commit
2a56e41fa9
1 changed files with 19 additions and 6 deletions
|
@ -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))
|
||||||
|
{
|
||||||
|
// "modified:" is automatically set to the current time when a task is
|
||||||
|
// 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);
|
context.tdb2.modify (task);
|
||||||
std::cout << " mod ";
|
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")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue