mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug - File open issue
- If a file (pending.data) is open and locked, trying to open it again caused an error, whereas is now does nothing and reports success. - Corrected timing info in Command::filter.
This commit is contained in:
parent
e403574c34
commit
ad38d5b92e
2 changed files with 20 additions and 17 deletions
27
src/File.cpp
27
src/File.cpp
|
@ -111,20 +111,25 @@ bool File::remove ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool File::open ()
|
bool File::open ()
|
||||||
{
|
{
|
||||||
if (data != "" && fh == NULL)
|
if (data != "")
|
||||||
{
|
{
|
||||||
bool already_exists = exists ();
|
if (! fh)
|
||||||
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);
|
bool already_exists = exists ();
|
||||||
locked = false;
|
if (already_exists)
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
|
@ -292,8 +292,6 @@ void Command::filter (std::vector <Task>& input, std::vector <Task>& output)
|
||||||
// Filter all tasks.
|
// Filter all tasks.
|
||||||
void Command::filter (std::vector <Task>& output)
|
void Command::filter (std::vector <Task>& output)
|
||||||
{
|
{
|
||||||
Timer timer ("Command::filter");
|
|
||||||
|
|
||||||
A3 filt = context.a3.extract_filter ();
|
A3 filt = context.a3.extract_filter ();
|
||||||
filt.dump ("extract_filter");
|
filt.dump ("extract_filter");
|
||||||
|
|
||||||
|
@ -304,6 +302,8 @@ void Command::filter (std::vector <Task>& output)
|
||||||
|
|
||||||
output.clear ();
|
output.clear ();
|
||||||
std::vector <Task>::const_iterator task;
|
std::vector <Task>::const_iterator task;
|
||||||
|
|
||||||
|
Timer timer ("Command::filter");
|
||||||
for (task = pending.begin (); task != pending.end (); ++task)
|
for (task = pending.begin (); task != pending.end (); ++task)
|
||||||
if (e.evalFilter (*task))
|
if (e.evalFilter (*task))
|
||||||
output.push_back (*task);
|
output.push_back (*task);
|
||||||
|
@ -311,6 +311,7 @@ void Command::filter (std::vector <Task>& output)
|
||||||
if (! filter_shortcut (filt))
|
if (! filter_shortcut (filt))
|
||||||
{
|
{
|
||||||
const std::vector <Task>& completed = context.tdb2.completed.get_tasks (); // TODO Optional
|
const std::vector <Task>& completed = context.tdb2.completed.get_tasks (); // TODO Optional
|
||||||
|
Timer timer ("Command::filter");
|
||||||
for (task = completed.begin (); task != completed.end (); ++task)
|
for (task = completed.begin (); task != completed.end (); ++task)
|
||||||
if (e.evalFilter (*task))
|
if (e.evalFilter (*task))
|
||||||
output.push_back (*task);
|
output.push_back (*task);
|
||||||
|
@ -320,7 +321,7 @@ void Command::filter (std::vector <Task>& output)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const std::vector <Task>& pending = context.tdb2.pending.get_tasks ();
|
const std::vector <Task>& pending = context.tdb2.pending.get_tasks ();
|
||||||
const std::vector <Task>& completed = context.tdb2.completed.get_tasks ();
|
const std::vector <Task>& completed = context.tdb2.completed.get_tasks ();
|
||||||
|
|
||||||
std::vector <Task>::const_iterator task;
|
std::vector <Task>::const_iterator task;
|
||||||
|
@ -418,9 +419,6 @@ void Command::modify_task (
|
||||||
std::string result = e.evalExpression (task);
|
std::string result = e.evalExpression (task);
|
||||||
context.debug (std::string ("Eval '") + value + "' --> '" + result + "'");
|
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.
|
// Dependencies must be resolved to UUIDs.
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue