mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Datafile: Throw exception if Datafile::deleteInterval fails
This is particularly bad when called from the Database::modifyInterval call, since the delete may fail, but then the addInterval will proceed. Closes #319 Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
This commit is contained in:
parent
48baa27057
commit
7481dab8d0
1 changed files with 8 additions and 4 deletions
|
@ -129,16 +129,20 @@ void Datafile::deleteInterval (const Interval& interval)
|
|||
assert (interval.startsWithin (_range));
|
||||
|
||||
if (! _lines_loaded)
|
||||
{
|
||||
load_lines ();
|
||||
}
|
||||
|
||||
auto serialized = interval.serialize ();
|
||||
auto i = std::find (_lines.begin (), _lines.end (), serialized);
|
||||
if (i != _lines.end ())
|
||||
if (i == _lines.end ())
|
||||
{
|
||||
_lines.erase (i);
|
||||
_dirty = true;
|
||||
debug (format ("{1}: Deleted {2}", _file.name (), serialized));
|
||||
throw format ("Datafile::deleteInterval failed to find '{1}'", serialized);
|
||||
}
|
||||
|
||||
_lines.erase (i);
|
||||
_dirty = true;
|
||||
debug (format ("{1}: Deleted {2}", _file.name (), serialized));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue