mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TDB2: Further gc() cleanup
This commit is contained in:
parent
ca9cd46f1c
commit
4424c5e450
1 changed files with 3 additions and 22 deletions
25
src/TDB2.cpp
25
src/TDB2.cpp
|
@ -1239,22 +1239,19 @@ void TDB2::gc ()
|
||||||
// Allowed as an override, but not recommended.
|
// Allowed as an override, but not recommended.
|
||||||
if (context.config.getBoolean ("gc"))
|
if (context.config.getBoolean ("gc"))
|
||||||
{
|
{
|
||||||
bool pending_changes = false;
|
|
||||||
bool completed_changes = false;
|
|
||||||
|
|
||||||
// Load pending, check whether completed changes size
|
// Load pending, check whether completed changes size
|
||||||
auto size_before = completed._tasks.size ();
|
auto size_before = completed._tasks.size ();
|
||||||
pending.load_tasks (/*from_gc =*/ true);
|
pending.load_tasks (/*from_gc =*/ true);
|
||||||
if (size_before != completed._tasks.size ())
|
if (size_before != completed._tasks.size ())
|
||||||
{
|
{
|
||||||
// GC moved tasks from pending to completed
|
// GC moved tasks from pending to completed
|
||||||
pending_changes = true;
|
pending._dirty = true;
|
||||||
completed_changes = true;
|
completed._dirty = true;
|
||||||
}
|
}
|
||||||
else if (pending._dirty)
|
else if (pending._dirty)
|
||||||
{
|
{
|
||||||
// A waiting task in pending was woken up
|
// A waiting task in pending was woken up
|
||||||
pending_changes = true;
|
pending._dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load completed, check whether pending changes size
|
// Load completed, check whether pending changes size
|
||||||
|
@ -1263,24 +1260,8 @@ void TDB2::gc ()
|
||||||
if (size_before != pending._tasks.size ())
|
if (size_before != pending._tasks.size ())
|
||||||
{
|
{
|
||||||
// GC moved tasks from completed to pending
|
// GC moved tasks from completed to pending
|
||||||
pending_changes = true;
|
|
||||||
completed_changes = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only recreate the pending.data file if necessary.
|
|
||||||
if (pending_changes)
|
|
||||||
{
|
|
||||||
pending._dirty = true;
|
pending._dirty = true;
|
||||||
|
|
||||||
// Note: deliberately no commit.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only recreate the completed.data file if necessary.
|
|
||||||
if (completed_changes)
|
|
||||||
{
|
|
||||||
completed._dirty = true;
|
completed._dirty = true;
|
||||||
|
|
||||||
// Note: deliberately no commit.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update blocked/blocking status after GC is finished
|
// Update blocked/blocking status after GC is finished
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue