MCPcopy Create free account
hub / github.com/YACReader/yacreader / updateFolder

Method updateFolder

YACReaderLibrary/library_creator.cpp:67–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void LibraryCreator::updateFolder(const QString &source, const QString &target, const QString &sourceFolder, qulonglong folderId)
68{
69 checkModifiedDatesOnUpdate = settings->value(COMPARE_MODIFIED_DATE_ON_LIBRARY_UPDATES, false).toBool();
70 partialUpdate = true;
71 _folderDestinationId = folderId;
72
73 _currentPathFolders.clear();
74
75 QString relativeFolderPath = sourceFolder;
76 relativeFolderPath = relativeFolderPath.remove(QDir::cleanPath(source));
77
78 if (relativeFolderPath.startsWith("/")) {
79 relativeFolderPath = relativeFolderPath.remove(0, 1); // remove firts '/'
80 }
81
82 QStringList folders;
83
84 if (!relativeFolderPath.isEmpty()) // updating root
85 {
86 folders = relativeFolderPath.split('/');
87 }
88
89 QLOG_DEBUG() << "folders found in relative path : " << folders << "-" << relativeFolderPath;
90 QString connectionName = "";
91 {
92 QSqlDatabase db = DataBaseManagement::loadDatabase(target);
93
94 if (!db.isValid()) {
95 QString error = "Unable to find database at: " + _target;
96 QLOG_ERROR() << error;
97 emit failedOpeningDB(error);
98 return;
99 }
100
101 _currentPathFolders.append(rootFolder(db));
102
103 for (const auto &folderName : folders) {
104 if (folderName.isEmpty()) {
105 break;
106 }
107 qulonglong parentId = _currentPathFolders.last().id;
108 _currentPathFolders.append(DBHelper::loadFolder(folderName, parentId, db));
109 QLOG_DEBUG() << "Folder appended : " << _currentPathFolders.last().id << " " << _currentPathFolders.last().name << " with parent" << _currentPathFolders.last().parentId;
110 }
111 connectionName = db.connectionName();
112 }
113 QSqlDatabase::removeDatabase(connectionName);
114
115 QLOG_DEBUG() << "Relative path : " << relativeFolderPath;
116
117 _sourceFolder = sourceFolder;
118
119 processLibrary(source, target);
120}
121
122void LibraryCreator::processLibrary(const QString &source, const QString &target)
123{

Callers

nothing calls this directly

Calls 6

rootFolderFunction · 0.85
isEmptyMethod · 0.80
splitMethod · 0.80
clearMethod · 0.45
removeMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected