diff --git a/src/File.cpp b/src/File.cpp index 884742555..fbe003d73 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -111,20 +111,25 @@ bool File::remove () //////////////////////////////////////////////////////////////////////////////// bool File::open () { - if (data != "" && fh == NULL) + if (data != "") { - bool already_exists = exists (); - if (already_exists) - if (!readable () || !writable ()) - throw std::string (format (STRING_FILE_PERMS, data)); - - fh = fopen (data.c_str (), (already_exists ? "r+" : "w+")); - if (fh) + if (! fh) { - h = fileno (fh); - locked = false; - return true; + bool already_exists = exists (); + if (already_exists) + if (!readable () || !writable ()) + throw std::string (format (STRING_FILE_PERMS, data)); + + fh = fopen (data.c_str (), (already_exists ? "r+" : "w+")); + if (fh) + { + h = fileno (fh); + locked = false; + return true; + } } + else + return true; } return false; diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 45a6a39ff..d3c247865 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -292,8 +292,6 @@ void Command::filter (std::vector & input, std::vector & output) // Filter all tasks. void Command::filter (std::vector & output) { - Timer timer ("Command::filter"); - A3 filt = context.a3.extract_filter (); filt.dump ("extract_filter"); @@ -304,6 +302,8 @@ void Command::filter (std::vector & output) output.clear (); std::vector ::const_iterator task; + + Timer timer ("Command::filter"); for (task = pending.begin (); task != pending.end (); ++task) if (e.evalFilter (*task)) output.push_back (*task); @@ -311,6 +311,7 @@ void Command::filter (std::vector & output) if (! filter_shortcut (filt)) { const std::vector & completed = context.tdb2.completed.get_tasks (); // TODO Optional + Timer timer ("Command::filter"); for (task = completed.begin (); task != completed.end (); ++task) if (e.evalFilter (*task)) output.push_back (*task); @@ -320,7 +321,7 @@ void Command::filter (std::vector & output) } else { - const std::vector & pending = context.tdb2.pending.get_tasks (); + const std::vector & pending = context.tdb2.pending.get_tasks (); const std::vector & completed = context.tdb2.completed.get_tasks (); std::vector ::const_iterator task; @@ -418,9 +419,6 @@ void Command::modify_task ( std::string result = e.evalExpression (task); context.debug (std::string ("Eval '") + value + "' --> '" + result + "'"); -//fragment.dump ("pre modify_task attr"); -//std::cout << "# modify_task result='" << result << "'\n"; - // Dependencies must be resolved to UUIDs. if (name == "depends") {