From 7892ba97e62772406f0c218b4864ac209aec48c2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 10 Jun 2020 13:09:39 +0400 Subject: [PATCH] Fix clearing storage_account files on logout. --- Telegram/SourceFiles/storage/localstorage.cpp | 14 -------------- Telegram/SourceFiles/storage/storage_account.cpp | 11 +++++++++++ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 7f4ca75ab6..28cfa0c5fd 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -1069,20 +1069,6 @@ void ClearManager::onStart() { switch (task) { case ClearManagerAll: { result = QDir(cTempDir()).removeRecursively(); - // #TODO - //QDirIterator di(_userBasePath, QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot); - //while (di.hasNext()) { - // di.next(); - // const QFileInfo& fi = di.fileInfo(); - // if (fi.isDir() && !fi.isSymLink()) { - // if (!QDir(di.filePath()).removeRecursively()) result = false; - // } else { - // QString path = di.filePath(); - // if (!path.endsWith(qstr("map0")) && !path.endsWith(qstr("map1")) && !path.endsWith(qstr("maps"))) { - // if (!QFile::remove(di.filePath())) result = false; - // } - // } - //} } break; case ClearManagerDownloads: result = QDir(cTempDir()).removeRecursively(); diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index c277d2245b..f229835f02 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -540,6 +540,7 @@ void Account::setPasscode(const QByteArray &passcode) { } void Account::reset() { + auto names = collectGoodNames(); _passcodeKeySalt.clear(); _draftsMap.clear(); _draftCursorsMap.clear(); @@ -564,6 +565,16 @@ void Account::reset() { _cacheBigFileTotalTimeLimit = Database::Settings().totalTimeLimit; _mapChanged = true; writeMap(); + + crl::async([base = _basePath, names = std::move(names)] { + for (const auto &name : names) { + if (!name.endsWith(qstr("map0")) + && !name.endsWith(qstr("map1")) + && !name.endsWith(qstr("maps"))) { + QFile::remove(base + name); + } + } + }); } void Account::writeLocations() {