MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / updateDocumentData

Method updateDocumentData

src/database/WizDatabase.cpp:3466–3509  ·  view source on GitHub ↗

* @brief Update document data by HTML text. * @param data Document metadata. * @param strHtml HTML text. * @param strURL Path to index.html of the document. * @param nFlags * @param notifyDataModify * @return */

Source from the content-addressed store, hash-verified

3464 * @return
3465 */
3466bool WizDatabase::updateDocumentData(WIZDOCUMENTDATA& data,
3467 const QString& strHtml,
3468 const QString& strURL,
3469 int nFlags,
3470 bool notifyDataModify /*= true*/)
3471{
3472 m_mtxTempFile.lock();
3473 QString strProcessedHtml(strHtml);
3474 // resources path "index_files"
3475 QString strResourcePath = GetResoucePathFromFile(strURL);
3476 if (!strResourcePath.isEmpty()) {
3477 // Replace all absolute URL with relative URL.
3478 QUrl urlResource = QUrl::fromLocalFile(strResourcePath);
3479 strProcessedHtml.replace(urlResource.toString(), "index_files/");
3480 }
3481 m_mtxTempFile.unlock();
3482 // check if note is encrypted or not
3483 if (isEncryptAllData())
3484 data.nProtected = 1;
3485 //
3486 WizDocument doc(*this, data);
3487 // compress files to zip
3488 CString strZipFileName = getDocumentFileName(data.strGUID);
3489 if (!data.nProtected) {
3490 bool bZip = ::WizHtml2Zip(strURL, strProcessedHtml, strResourcePath, nFlags, strZipFileName);
3491 if (!bZip) {
3492 return false;
3493 }
3494 } else {
3495 CString strTempFile = Utils::WizPathResolve::tempPath() + data.strGUID + "-decrypted";
3496 bool bZip = ::WizHtml2Zip(strURL, strProcessedHtml, strResourcePath, nFlags, strTempFile);
3497 if (!bZip) {
3498 return false;
3499 }
3500
3501 if (!m_ziwReader->encryptFileToFile(strTempFile, strZipFileName)) {
3502 return false;
3503 }
3504 }
3505
3506 setObjectDataDownloaded(data.strGUID, "document", true);
3507
3508 return updateDocumentDataMD5(data, strZipFileName, notifyDataModify);
3509}
3510
3511
3512bool WizDatabase::updateDocumentDataWithFolder(WIZDOCUMENTDATA& data,

Callers 6

UpdateDocument3Method · 0.80
UpdateDocument4Method · 0.80
UpdateDocument6Method · 0.80
runMethod · 0.80
saveSvgCoreFunction · 0.80

Calls 7

GetResoucePathFromFileFunction · 0.85
WizHtml2ZipFunction · 0.85
lockMethod · 0.80
isEmptyMethod · 0.80
unlockMethod · 0.80
encryptFileToFileMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected