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

Method check

Telegram/SourceFiles/core/file_location.cpp:78–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78bool FileLocation::check() const {
79 if (fname.isEmpty() || fname == kInMediaCacheLocation) {
80 return false;
81 }
82
83 ReadAccessEnabler enabler(_bookmark);
84 if (enabler.failed()) {
85 const_cast<FileLocation*>(this)->_bookmark = nullptr;
86 }
87
88 QFileInfo f(name());
89 if (!f.isReadable()) return false;
90
91 quint64 s = f.size();
92 if (s > kMaxFileSize) {
93 DEBUG_LOG(("File location check: Wrong size %1").arg(s));
94 return false;
95 }
96
97 if (s != size) {
98 DEBUG_LOG(("File location check: Wrong size %1 when should be %2").arg(s).arg(size));
99 return false;
100 }
101 auto realModified = f.lastModified();
102 if (realModified != modified) {
103 DEBUG_LOG(("File location check: Wrong last modified time %1 when should be %2").arg(realModified.toMSecsSinceEpoch()).arg(modified.toMSecsSinceEpoch()));
104 return false;
105 }
106 return true;
107}
108
109const QString &FileLocation::name() const {
110 return _bookmark ? _bookmark->name(fname) : fname;

Callers

nothing calls this directly

Calls 4

nameFunction · 0.85
isEmptyMethod · 0.45
failedMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected