From e8ead2974b7918fd50a0b7759a0805c5d0136fb0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 9 Feb 2017 16:51:49 +0300 Subject: [PATCH] Added logging of file location invalidations. If file size or file last modified time were changed we invalidate our known location for a downloaded file. Now we log those events to DebugLogs to see if they're responsible for reported download problems. --- Telegram/SourceFiles/ui/images.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index 0c9b71528..38931abc4 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -1242,9 +1242,21 @@ bool FileLocation::check() const { if (!f.isReadable()) return false; quint64 s = f.size(); - if (s > INT_MAX) return false; + if (s > INT_MAX) { + DEBUG_LOG(("File location check: Wrong size %1").arg(s)); + return false; + } - return (f.lastModified() == modified) && (qint32(s) == size); + if (qint32(s) != size) { + DEBUG_LOG(("File location check: Wrong size %1 when should be %2").arg(s).arg(size)); + return false; + } + auto realModified = f.lastModified(); + if (realModified != modified) { + DEBUG_LOG(("File location check: Wrong last modified time %1 when should be %2").arg(realModified.toMSecsSinceEpoch()).arg(modified.toMSecsSinceEpoch())); + return false; + } + return true; } const QString &FileLocation::name() const {