MCPcopy Create free account
hub / github.com/LeFroid/Viper-Browser / updateSubscriptions

Method updateSubscriptions

src/core/adblock/AdBlockManager.cpp:87–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void AdBlockManager::updateSubscriptions()
88{
89 if (!m_enabled)
90 return;
91
92 // Try updating the subscription if its next_update is hit
93 // Check if subscription should be updated
94 for (size_t i = 0; i < m_subscriptions.size(); ++i)
95 {
96 AdBlockSubscription *subPtr = &(m_subscriptions[i]);
97 if (!subPtr)
98 continue;
99 const QDateTime &updateTime = subPtr->getNextUpdate();
100 QDateTime now = QDateTime::currentDateTime();
101 if (!updateTime.isNull() && updateTime < now)
102 {
103 const QUrl &srcUrl = subPtr->getSourceUrl();
104 if (srcUrl.isValid() && !srcUrl.isLocalFile())
105 {
106 QNetworkRequest request;
107 request.setUrl(srcUrl);
108
109 InternalDownloadItem *item = m_downloadManager->downloadInternal(request, m_subscriptionDir, false, true);
110 connect(item, &InternalDownloadItem::downloadFinished, [item, now, subPtr](const QString &filePath) {
111 if (filePath != subPtr->getFilePath())
112 {
113 QFile oldFile(subPtr->getFilePath());
114 oldFile.remove();
115 subPtr->setFilePath(filePath);
116 }
117 item->deleteLater();
118 subPtr->setLastUpdate(now);
119 subPtr->setNextUpdate(now.addDays(7));
120 });
121 }
122 }
123 }
124}
125
126void AdBlockManager::installResource(const QUrl &url)
127{

Callers 1

getNewWindowMethod · 0.45

Calls 5

setUrlMethod · 0.80
downloadInternalMethod · 0.80
setFilePathMethod · 0.80
setLastUpdateMethod · 0.80
setNextUpdateMethod · 0.80

Tested by

no test coverage detected