mirror of https://github.com/procxx/kepka.git
added some additional logging for file downloadings
This commit is contained in:
parent
ddc802c0af
commit
47c7f76f2c
|
@ -188,7 +188,6 @@ if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$Build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DeployMac" == "1" ]; then
|
if [ "$DeployMac" == "1" ]; then
|
||||||
cp -v "$DeployPath/$UpdateFile" "$DropboxDeployPath/"
|
|
||||||
cp -v "$DeployPath/$SetupFile" "$DropboxDeployPath/$DropboxSetupFile"
|
cp -v "$DeployPath/$SetupFile" "$DropboxDeployPath/$DropboxSetupFile"
|
||||||
if [ -d "$DropboxDeployPath/Telegram.app.dSYM" ]; then
|
if [ -d "$DropboxDeployPath/Telegram.app.dSYM" ]; then
|
||||||
rm -rf "$DropboxDeployPath/Telegram.app.dSYM"
|
rm -rf "$DropboxDeployPath/Telegram.app.dSYM"
|
||||||
|
@ -196,7 +195,6 @@ if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$Build
|
||||||
cp -rv "$DeployPath/Telegram.app.dSYM" "$DropboxDeployPath/"
|
cp -rv "$DeployPath/Telegram.app.dSYM" "$DropboxDeployPath/"
|
||||||
fi
|
fi
|
||||||
if [ "$DeployMac32" == "1" ]; then
|
if [ "$DeployMac32" == "1" ]; then
|
||||||
mv -v "$Mac32DeployPath/$Mac32UpdateFile" "$DropboxDeployPath/"
|
|
||||||
mv -v "$Mac32DeployPath/$Mac32SetupFile" "$DropboxDeployPath/$DropboxMac32SetupFile"
|
mv -v "$Mac32DeployPath/$Mac32SetupFile" "$DropboxDeployPath/$DropboxMac32SetupFile"
|
||||||
if [ -d "$DropboxDeployPath/Telegram32.app.dSYM" ]; then
|
if [ -d "$DropboxDeployPath/Telegram32.app.dSYM" ]; then
|
||||||
rm -rf "$DropboxDeployPath/Telegram32.app.dSYM"
|
rm -rf "$DropboxDeployPath/Telegram32.app.dSYM"
|
||||||
|
@ -207,7 +205,6 @@ if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$Build
|
||||||
mv -v "$WinDeployPath/Telegram.pdb" "$DropboxDeployPath/"
|
mv -v "$WinDeployPath/Telegram.pdb" "$DropboxDeployPath/"
|
||||||
mv -v "$WinDeployPath/Updater.exe" "$DropboxDeployPath/"
|
mv -v "$WinDeployPath/Updater.exe" "$DropboxDeployPath/"
|
||||||
mv -v "$WinDeployPath/Updater.pdb" "$DropboxDeployPath/"
|
mv -v "$WinDeployPath/Updater.pdb" "$DropboxDeployPath/"
|
||||||
mv -v "$WinDeployPath/$WinUpdateFile" "$DropboxDeployPath/"
|
|
||||||
if [ "$BetaVersion" == "0" ]; then
|
if [ "$BetaVersion" == "0" ]; then
|
||||||
mv -v "$WinDeployPath/$WinSetupFile" "$DropboxDeployPath/"
|
mv -v "$WinDeployPath/$WinSetupFile" "$DropboxDeployPath/"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -355,6 +355,8 @@ struct GlobalDataStruct {
|
||||||
Adaptive::Layout AdaptiveLayout = Adaptive::NormalLayout;
|
Adaptive::Layout AdaptiveLayout = Adaptive::NormalLayout;
|
||||||
bool AdaptiveForWide = true;
|
bool AdaptiveForWide = true;
|
||||||
|
|
||||||
|
int32 DebugLoggingFlags = 0;
|
||||||
|
|
||||||
// config
|
// config
|
||||||
int32 ChatSizeMax = 200;
|
int32 ChatSizeMax = 200;
|
||||||
int32 MegagroupSizeMax = 1000;
|
int32 MegagroupSizeMax = 1000;
|
||||||
|
@ -398,6 +400,8 @@ namespace Global {
|
||||||
DefineVar(Global, Adaptive::Layout, AdaptiveLayout);
|
DefineVar(Global, Adaptive::Layout, AdaptiveLayout);
|
||||||
DefineVar(Global, bool, AdaptiveForWide);
|
DefineVar(Global, bool, AdaptiveForWide);
|
||||||
|
|
||||||
|
DefineVar(Global, int32, DebugLoggingFlags);
|
||||||
|
|
||||||
// config
|
// config
|
||||||
DefineVar(Global, int32, ChatSizeMax);
|
DefineVar(Global, int32, ChatSizeMax);
|
||||||
DefineVar(Global, int32, MegagroupSizeMax);
|
DefineVar(Global, int32, MegagroupSizeMax);
|
||||||
|
|
|
@ -131,6 +131,12 @@ namespace Adaptive {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace DebugLogging {
|
||||||
|
enum Flags {
|
||||||
|
FileLoaderFlag = 0x00000001,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace Global {
|
namespace Global {
|
||||||
|
|
||||||
bool started();
|
bool started();
|
||||||
|
@ -142,6 +148,8 @@ namespace Global {
|
||||||
DeclareVar(Adaptive::Layout, AdaptiveLayout);
|
DeclareVar(Adaptive::Layout, AdaptiveLayout);
|
||||||
DeclareVar(bool, AdaptiveForWide);
|
DeclareVar(bool, AdaptiveForWide);
|
||||||
|
|
||||||
|
DeclareVar(int32, DebugLoggingFlags);
|
||||||
|
|
||||||
// config
|
// config
|
||||||
DeclareVar(int32, ChatSizeMax);
|
DeclareVar(int32, ChatSizeMax);
|
||||||
DeclareVar(int32, MegagroupSizeMax);
|
DeclareVar(int32, MegagroupSizeMax);
|
||||||
|
@ -175,3 +183,9 @@ namespace Adaptive {
|
||||||
return Global::AdaptiveForWide() && (Global::AdaptiveLayout() == WideLayout);
|
return Global::AdaptiveForWide() && (Global::AdaptiveLayout() == WideLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace DebugLogging {
|
||||||
|
inline bool FileLoader() {
|
||||||
|
return (Global::DebugLoggingFlags() | FileLoaderFlag) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -376,9 +376,33 @@ int32 mtpFileLoader::currentOffset(bool includeSkipped) const {
|
||||||
return (_fileIsOpen ? _file.size() : _data.size()) - (includeSkipped ? 0 : _skippedBytes);
|
return (_fileIsOpen ? _file.size() : _data.size()) - (includeSkipped ? 0 : _skippedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
QString serializereqs(const QMap<mtpRequestId, int32> &reqs) { // serialize requests map in json-like format
|
||||||
|
QString result;
|
||||||
|
result.reserve(reqs.size() * 16 + 4);
|
||||||
|
result.append(qsl("{ "));
|
||||||
|
for (auto i = reqs.cbegin(), e = reqs.cend(); i != e;) {
|
||||||
|
result.append(QString::number(i.key())).append(qsl(" : ")).append(QString::number(i.value()));
|
||||||
|
if (++i == e) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
result.append(qsl(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.append(qsl(" }"));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool mtpFileLoader::loadPart() {
|
bool mtpFileLoader::loadPart() {
|
||||||
if (_complete || _lastComplete || (!_requests.isEmpty() && !_size)) return false;
|
if (_complete || _lastComplete || (!_requests.isEmpty() && !_size)) {
|
||||||
if (_size && _nextRequestOffset >= _size) return false;
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): loadPart() returned, _complete=%2, _lastComplete=%3, _requests.size()=%4, _size=%5").arg(_id).arg(Logs::b(_complete)).arg(Logs::b(_lastComplete)).arg(_requests.size()).arg(_size));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_size && _nextRequestOffset >= _size) {
|
||||||
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): loadPart() returned, _size=%2, _nextRequestOffset=%3, _requests=%4").arg(_id).arg(_size).arg(_nextRequestOffset).arg(serializereqs(_requests)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int32 limit = DocumentDownloadPartSize;
|
int32 limit = DocumentDownloadPartSize;
|
||||||
MTPInputFileLocation loc;
|
MTPInputFileLocation loc;
|
||||||
|
@ -412,12 +436,21 @@ bool mtpFileLoader::loadPart() {
|
||||||
_requests.insert(reqId, dcIndex);
|
_requests.insert(reqId, dcIndex);
|
||||||
_nextRequestOffset += limit;
|
_nextRequestOffset += limit;
|
||||||
|
|
||||||
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): requested part with offset=%2, _queue->queries=%3, _nextRequestOffset=%4, _requests=%5").arg(_id).arg(offset).arg(_queue->queries).arg(_nextRequestOffset).arg(serializereqs(_requests)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRequestId req) {
|
void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRequestId req) {
|
||||||
Requests::iterator i = _requests.find(req);
|
Requests::iterator i = _requests.find(req);
|
||||||
if (i == _requests.cend()) return loadNext();
|
if (i == _requests.cend()) {
|
||||||
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): request req=%2 for offset=%3 not found in _requests=%4").arg(_id).arg(req).arg(offset).arg(serializereqs(_requests)));
|
||||||
|
return loadNext();
|
||||||
|
}
|
||||||
|
if (result.type() != mtpc_upload_file) {
|
||||||
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): bad cons received! %2").arg(_id).arg(result.type()));
|
||||||
|
return cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
int32 limit = (_locationType == UnknownFileLocation) ? DownloadPartSize : DocumentDownloadPartSize;
|
int32 limit = (_locationType == UnknownFileLocation) ? DownloadPartSize : DocumentDownloadPartSize;
|
||||||
int32 dcIndex = i.value();
|
int32 dcIndex = i.value();
|
||||||
|
@ -428,6 +461,9 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||||
|
|
||||||
const MTPDupload_file &d(result.c_upload_file());
|
const MTPDupload_file &d(result.c_upload_file());
|
||||||
const string &bytes(d.vbytes.c_string().v);
|
const string &bytes(d.vbytes.c_string().v);
|
||||||
|
|
||||||
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): got part with offset=%2, bytes=%3, _queue->queries=%4, _nextRequestOffset=%5, _requests=%6").arg(_id).arg(offset).arg(bytes.size()).arg(_queue->queries).arg(_nextRequestOffset).arg(serializereqs(_requests)));
|
||||||
|
|
||||||
if (bytes.size()) {
|
if (bytes.size()) {
|
||||||
if (_fileIsOpen) {
|
if (_fileIsOpen) {
|
||||||
int64 fsize = _file.size();
|
int64 fsize = _file.size();
|
||||||
|
@ -502,6 +538,8 @@ void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRe
|
||||||
Local::writeImage(storageKey(*_location), StorageImageSaved(mtpToStorageType(_type), _data));
|
Local::writeImage(storageKey(*_location), StorageImageSaved(mtpToStorageType(_type), _data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): not done yet, _lastComplete=%2, _size=%3, _nextRequestOffset=%4, _requests=%5").arg(_id).arg(Logs::b(_lastComplete)).arg(_size).arg(_nextRequestOffset).arg(serializereqs(_requests)));
|
||||||
}
|
}
|
||||||
emit progress(this);
|
emit progress(this);
|
||||||
loadNext();
|
loadNext();
|
||||||
|
|
|
@ -813,9 +813,21 @@ void SettingsInner::keyPressEvent(QKeyEvent *e) {
|
||||||
break;
|
break;
|
||||||
} else if (str == qstr("loadlang")) {
|
} else if (str == qstr("loadlang")) {
|
||||||
chooseCustomLang();
|
chooseCustomLang();
|
||||||
|
} else if (str == qstr("debugfiles") && cDebug()) {
|
||||||
|
if (DebugLogging::FileLoader()) {
|
||||||
|
Global::RefDebugLoggingFlags() &= ~DebugLogging::FileLoaderFlag;
|
||||||
|
} else {
|
||||||
|
Global::RefDebugLoggingFlags() |= DebugLogging::FileLoaderFlag;
|
||||||
|
}
|
||||||
|
Ui::showLayer(new InformBox(DebugLogging::FileLoader() ? "Enabled file download logging" : "Disabled file download logging"));
|
||||||
} else if (str == qstr("crashplease")) {
|
} else if (str == qstr("crashplease")) {
|
||||||
t_assert(!"Crashed in Settings!");
|
t_assert(!"Crashed in Settings!");
|
||||||
} else if (qsl("debugmode").startsWith(str) || qsl("testmode").startsWith(str) || qsl("loadlang").startsWith(str) || qsl("crashplease").startsWith(str)) {
|
} else if (
|
||||||
|
qsl("debugmode").startsWith(str) ||
|
||||||
|
qsl("testmode").startsWith(str) ||
|
||||||
|
qsl("loadlang").startsWith(str) ||
|
||||||
|
qsl("debugfiles").startsWith(str) ||
|
||||||
|
qsl("crashplease").startsWith(str)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++from;
|
++from;
|
||||||
|
|
Loading…
Reference in New Issue