Akonadi

storagejanitor.h
1 /*
2  SPDX-FileCopyrightText: 2011 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "akthread.h"
10 
11 #include <QDBusConnection>
12 
13 namespace Akonadi
14 {
15 namespace Server
16 {
17 class Collection;
18 class AkonadiServer;
19 
20 /**
21  * Various database checking/maintenance features.
22  */
23 class StorageJanitor : public AkThread
24 {
25  Q_OBJECT
26  Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.Janitor")
27 
28 public:
29  explicit StorageJanitor(AkonadiServer &mAkonadi);
30  ~StorageJanitor() override;
31 
32 public Q_SLOTS:
33  /** Triggers a consistency check of the internal storage. */
34  Q_SCRIPTABLE Q_NOREPLY void check();
35  /** Triggers a vacuuming of the database, that is compacting of unused space. */
36  Q_SCRIPTABLE Q_NOREPLY void vacuum();
37 
38 Q_SIGNALS:
39  /** Sends informational messages to a possible UI for this. */
40  Q_SCRIPTABLE void information(const QString &msg);
41  Q_SCRIPTABLE void done();
42 
43 protected:
44  void init() override;
45  void quit() override;
46 
47 private:
48  void inform(const char *msg);
49  void inform(const QString &msg);
50  /** Create a lost+found collection if necessary. */
51  qint64 lostAndFoundCollection();
52 
53  /**
54  * Look for resources in the DB not existing in reality.
55  */
56  void findOrphanedResources();
57 
58  /**
59  * Look for collections belonging to non-existent resources.
60  */
61  void findOrphanedCollections();
62 
63  /**
64  * Verifies there is a path from @p col to the root of the collection tree
65  * and that everything along that path belongs to the same resource.
66  */
67  void checkPathToRoot(const Collection &col);
68 
69  /**
70  * Look for items belonging to non-existing collections.
71  */
72  void findOrphanedItems();
73 
74  /**
75  * Look for parts belonging to non-existing items.
76  */
77  void findOrphanedParts();
78 
79  /**
80  * Look for item flags belonging to non-existing items.
81  */
82  void findOrphanedPimItemFlags();
83 
84  /**
85  * Look for parts referring to the same external file.
86  */
87  void findOverlappingParts();
88 
89  /**
90  * Verify fs and db part state.
91  */
92  void verifyExternalParts();
93 
94  /**
95  * Look for dirty objects.
96  */
97  void findDirtyObjects();
98 
99  /**
100  * Look for duplicates by RID.
101  *
102  * ..and remove the one that doesn't match the parent collections content mimetype.
103  */
104  void findRIDDuplicates();
105 
106  /**
107  * Check whether part sizes match what's in database.
108  *
109  * If SizeTreshold has change, it will move parts from or to database
110  * where necessary.
111  */
112  void checkSizeTreshold();
113 
114  /**
115  * Check if all external payload files are migrated to the levelled folder
116  * hierarchy and migrates them if necessary
117  */
118  void migrateToLevelledCacheHierarchy();
119 
120  /**
121  * Check if the search index contains any entries that refer to Akonadi
122  * Items that no longer exist in the DB.
123  */
124  void findOrphanSearchIndexEntries();
125 
126  /**
127  * Make sure that the "Search" collection in the virtual search resource
128  * exists. It is only created during database initialization, so if user
129  * somehow manages to delete it, their search would be completely borked.
130  */
131  void ensureSearchCollection();
132 
133 private:
134  qint64 m_lostFoundCollectionId;
135  AkonadiServer &m_akonadi;
136 };
137 
138 } // namespace Server
139 } // namespace Akonadi
140 
Q_OBJECTQ_OBJECT
Q_SCRIPTABLE Q_NOREPLY void check()
Triggers a consistency check of the internal storage.
Q_SLOTSQ_SLOTS
Q_CLASSINFO(Name, Value)
Represents a collection of PIM items.
Definition: collection.h:61
Q_SCRIPTABLE void information(const QString &msg)
Sends informational messages to a possible UI for this.
Q_SIGNALSQ_SIGNALS
Q_SCRIPTABLE Q_NOREPLY void vacuum()
Triggers a vacuuming of the database, that is compacting of unused space.
Various database checking/maintenance features.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.