data_transfer: avoid to crash if directory doesn't exist

This fix testReplayConversation

Change-Id: If760f08c31995a84c8818e1d0f4586865cfec5a9
This commit is contained in:
Sébastien Blin
2024-01-02 14:36:14 -05:00
committed by Adrien Béraud
parent 8065504bb0
commit b627aa9c57

View File

@ -553,9 +553,10 @@ TransferManager::onIncomingProfile(const std::shared_ptr<dhtnet::ChannelSocket>&
auto& pimpl = sthis_->pimpl_;
auto destPath = sthis_->profilePath(uri);
{
try {
// Move profile to destination path
std::lock_guard lock(dhtnet::fileutils::getFileLock(destPath));
dhtnet::fileutils::recursive_mkdir(destPath.parent_path());
std::filesystem::rename(path, destPath);
if (!pimpl->accountUri_.empty() && uri == pimpl->accountUri_) {
// If this is the account profile, link or copy it to the account profile path
@ -564,6 +565,8 @@ TransferManager::onIncomingProfile(const std::shared_ptr<dhtnet::ChannelSocket>&
std::filesystem::copy_file(destPath, pimpl->accountProfilePath_, ec);
}
}
} catch (const std::exception& e) {
JAMI_ERROR("{}", e.what());
}
std::lock_guard lk {pimpl->mapMutex_};