MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / saveFromDataChecked

Method saveFromDataChecked

Telegram/SourceFiles/data/data_document.cpp:1451–1473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1449}
1450
1451bool DocumentData::saveFromDataChecked() {
1452 const auto media = activeMediaView();
1453 if (!media) {
1454 return false;
1455 }
1456 const auto bytes = media->bytes();
1457 if (bytes.isEmpty()) {
1458 return false;
1459 }
1460 const auto path = DocumentFileNameForSave(this);
1461 if (path.isEmpty()) {
1462 return false;
1463 }
1464 auto file = QFile(path);
1465 if (!file.open(QIODevice::WriteOnly)
1466 || file.write(bytes) != bytes.size()) {
1467 return false;
1468 }
1469 file.close();
1470 _location = Core::FileLocation(path);
1471 session().local().writeFileLocation(mediaKey(), _location);
1472 return true;
1473}
1474
1475void DocumentData::refreshPossibleCoverThumbnail() {
1476 Expects(isSong());

Callers

nothing calls this directly

Calls 10

DocumentFileNameForSaveFunction · 0.85
mediaKeyFunction · 0.85
bytesMethod · 0.80
writeFileLocationMethod · 0.80
FileLocationClass · 0.50
isEmptyMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected