Changeset View
Changeset View
Standalone View
Standalone View
src/engine/documenturldb.h
Show All 17 Lines | |||||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #ifndef BALOO_DOCUMENTURLDB_H | 21 | #ifndef BALOO_DOCUMENTURLDB_H | ||
22 | #define BALOO_DOCUMENTURLDB_H | 22 | #define BALOO_DOCUMENTURLDB_H | ||
23 | 23 | | |||
24 | #include "idtreedb.h" | 24 | #include "idtreedb.h" | ||
25 | #include "idfilenamedb.h" | 25 | #include "idfilenamedb.h" | ||
26 | #include "idutils.h" | ||||
26 | 27 | | |||
27 | #include <QDebug> | 28 | #include <QDebug> | ||
28 | #include <QFile> | 29 | #include <QFile> | ||
29 | 30 | | |||
30 | namespace Baloo { | 31 | namespace Baloo { | ||
31 | 32 | | |||
32 | class UrlTest; | 33 | class UrlTest; | ||
33 | class PostingIterator; | 34 | class PostingIterator; | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 108 | { | |||
108 | IdFilenameDB idFilenameDb(m_idFilenameDbi, m_txn); | 109 | IdFilenameDB idFilenameDb(m_idFilenameDbi, m_txn); | ||
109 | IdTreeDB idTreeDb(m_idTreeDbi, m_txn); | 110 | IdTreeDB idTreeDb(m_idTreeDbi, m_txn); | ||
110 | 111 | | |||
111 | // FIXME: Maybe this can be combined into one? | 112 | // FIXME: Maybe this can be combined into one? | ||
112 | auto path = idFilenameDb.get(docId); | 113 | auto path = idFilenameDb.get(docId); | ||
113 | if (path.name.isEmpty()) { | 114 | if (path.name.isEmpty()) { | ||
114 | return; | 115 | return; | ||
115 | } | 116 | } | ||
117 | | ||||
118 | // Check for trivial case - simple rename, i.e. parent stays the same | ||||
119 | if (!url.isEmpty()) { | ||||
120 | auto lastSlash = url.lastIndexOf('/'); | ||||
121 | auto parentPath = url.left(lastSlash + 1); | ||||
122 | auto parentId = filePathToId(parentPath); | ||||
123 | if (!parentId) { | ||||
124 | qDebug() << "parent" << parentPath << "of" << url << "does not exist"; | ||||
125 | return; | ||||
126 | | ||||
127 | } else if (parentId == path.parentId) { | ||||
128 | auto newname = url.mid(lastSlash + 1); | ||||
129 | qDebug() << docId << url << "renaming" << path.name << "to" << newname; | ||||
130 | path.name = newname; | ||||
131 | idFilenameDb.put(docId, path); | ||||
132 | return; | ||||
133 | } | ||||
134 | } | ||||
135 | | ||||
116 | idFilenameDb.del(docId); | 136 | idFilenameDb.del(docId); | ||
117 | 137 | | |||
118 | QVector<quint64> subDocs = idTreeDb.get(path.parentId); | 138 | QVector<quint64> subDocs = idTreeDb.get(path.parentId); | ||
119 | subDocs.removeOne(docId); | 139 | subDocs.removeOne(docId); | ||
120 | 140 | | |||
121 | if (!subDocs.isEmpty()) { | 141 | if (!subDocs.isEmpty()) { | ||
122 | idTreeDb.put(path.parentId, subDocs); | 142 | idTreeDb.put(path.parentId, subDocs); | ||
123 | } else { | 143 | } else { | ||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |