From 2a56e41fa997d6a3ba788698d870627df4e64487 Mon Sep 17 00:00:00 2001 From: Wilhelm Schuermann Date: Sat, 30 May 2015 12:40:38 +0200 Subject: [PATCH] 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. --- src/commands/CmdImport.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index d466ee65a..9cd3df821 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -112,19 +112,32 @@ int CmdImport::import (std::vector & lines) Task task (object); // Check whether the imported task is new or a modified existing task. - Task dummy; - if (context.tdb2.get (task.get ("uuid"), dummy)) + Task before; + if (context.tdb2.get (task.get ("uuid"), before)) { - context.tdb2.modify (task); - std::cout << " mod "; + // "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); + std::cout << " mod "; + ++count; + } + else + { + std::cout << " skip "; + } } else { context.tdb2.add (task); - std::cout << " add "; + std::cout << " add "; + ++count; } - ++count; std::cout << task.get ("uuid") << " " << task.get ("description")