Fix clearing storage_account files on logout.

This commit is contained in:
John Preston 2020-06-10 13:09:39 +04:00
parent ad4afe9293
commit 7892ba97e6
2 changed files with 11 additions and 14 deletions

View File

@ -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();

View File

@ -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() {