SecureId: minor files upload/download bugfix

GitOrigin-RevId: 8ba92f2d0e6f9098d36c68700edf15f452dd1ffa
This commit is contained in:
Arseny Smirnov 2018-05-30 19:57:49 +03:00
parent c783a946c3
commit 6188a6c118
2 changed files with 3 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include "td/utils/port/Stat.h" #include "td/utils/port/Stat.h"
#include "td/utils/ScopeGuard.h" #include "td/utils/ScopeGuard.h"
#include "td/utils/Slice.h" #include "td/utils/Slice.h"
#include "td/utils/port/path.h"
#include <tuple> #include <tuple>
@ -117,6 +118,7 @@ Status FileDownloader::on_ok(int64 size) {
string tmp_path; string tmp_path;
std::tie(std::ignore, tmp_path) = std::move(file_path); std::tie(std::ignore, tmp_path) = std::move(file_path);
TRY_STATUS(secure_storage::decrypt_file(encryption_key_.secret(), encryption_key_.value_hash(), path_, tmp_path)); TRY_STATUS(secure_storage::decrypt_file(encryption_key_.secret(), encryption_key_.value_hash(), path_, tmp_path));
unlink(path_).ignore();
path_ = std::move(tmp_path); path_ = std::move(tmp_path);
TRY_RESULT(path_stat, stat(path_)); TRY_RESULT(path_stat, stat(path_));
size = path_stat.size_; size = path_stat.size_;

View File

@ -123,6 +123,7 @@ Result<FileLoader::PrefixInfo> FileUploader::on_update_local_location(const Loca
TRY_RESULT(hash, secure_storage::encrypt_file(encryption_key_.secret(), path, new_path)); TRY_RESULT(hash, secure_storage::encrypt_file(encryption_key_.secret(), path, new_path));
LOG(INFO) << "ENCRYPT " << path << " " << new_path; LOG(INFO) << "ENCRYPT " << path << " " << new_path;
callback_->on_hash(hash.as_slice().str()); callback_->on_hash(hash.as_slice().str());
unlink(path).ignore();
path = new_path; path = new_path;
is_temp = true; is_temp = true;
} }