mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Database: Now tracks the need to write data with ::_dirty
This commit is contained in:
parent
2cd945e440
commit
8c74b0e1e9
2 changed files with 17 additions and 0 deletions
|
@ -60,6 +60,16 @@ void Database::initialize (const std::string& location)
|
|||
// TODO If there is no data file named YYYY—MM.data, then create it.
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Database::commit ()
|
||||
{
|
||||
if (_dirty)
|
||||
{
|
||||
|
||||
_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Interval Database::getLatestInterval () const
|
||||
{
|
||||
|
@ -70,18 +80,21 @@ Interval Database::getLatestInterval () const
|
|||
void Database::addExclusion (const std::string& exclusion)
|
||||
{
|
||||
_files[0].addExclusion (exclusion);
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Database::addInterval (const Interval& interval)
|
||||
{
|
||||
_files[0].addInterval (interval);
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Database::modifyInterval (const Interval& interval)
|
||||
{
|
||||
_files[0].modifyInterval (interval);
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -94,6 +107,8 @@ std::string Database::dump () const
|
|||
<< (file.name () == _current ? " (current)" : "")
|
||||
<< "\n";
|
||||
|
||||
out << " Dirty: " << (_dirty ? "true" : "false") << "\n";
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class Database
|
|||
public:
|
||||
Database () = default;
|
||||
void initialize (const std::string&);
|
||||
void commit ();
|
||||
|
||||
Interval getLatestInterval () const;
|
||||
|
||||
|
@ -53,6 +54,7 @@ private:
|
|||
std::string _location {"~/.timewarrior/data"};
|
||||
std::string _current {};
|
||||
std::vector <Datafile> _files {};
|
||||
bool _dirty {false};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue