prevent the auto accept when file already exists
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / linux-debian12 (push) Has been cancelled
ContinuousDelivery / windows (windows-2022, ) (push) Has been cancelled
ContinuousDelivery / windows (windows-2022, asan) (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
ContinuousIntegration / linux-ubuntu-latest (push) Has been cancelled
ContinuousIntegration / linux-debian12 (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousIntegration / macos-latest (push) Has been cancelled
ContinuousIntegration / windows-latest (push) Has been cancelled

This commit is contained in:
Green Sky
2026-01-10 17:13:21 +01:00
parent 01c1992875
commit a9b27fe9b7

View File

@@ -8,6 +8,7 @@
#include <solanaceae/util/config_model.hpp> #include <solanaceae/util/config_model.hpp>
#include <filesystem>
#include <iostream> #include <iostream>
TransferAutoAccept::TransferAutoAccept(ObjectStore2& os, RegistryMessageModelI& rmm, ConfigModelI& conf) : _os(os), _rmm(rmm), _conf(conf) { TransferAutoAccept::TransferAutoAccept(ObjectStore2& os, RegistryMessageModelI& rmm, ConfigModelI& conf) : _os(os), _rmm(rmm), _conf(conf) {
@@ -77,17 +78,23 @@ void TransferAutoAccept::checkObj(ObjectHandle o) {
return; return;
} }
const auto save_dir_path = _conf.get_string("TransferAutoAccept", "save_path").value_or("tmp_save_dir");
uint64_t total_size {0u}; uint64_t total_size {0u};
if (const auto* si = o.try_get<ObjComp::F::SingleInfo>(); si != nullptr) { if (const auto* si = o.try_get<ObjComp::F::SingleInfo>(); si != nullptr) {
if (si->file_name.empty()) { if (si->file_name.empty()) {
return; // bad file return; // bad file
} }
total_size = si->file_size; total_size = si->file_size;
if (std::filesystem::exists(std::filesystem::path(save_dir_path) / si->file_name)) {
return; // pre existing, dont auto
}
} else if (const auto* ci = o.try_get<ObjComp::F::CollectionInfo>(); ci != nullptr) { } else if (const auto* ci = o.try_get<ObjComp::F::CollectionInfo>(); ci != nullptr) {
if (ci->file_list.empty() || ci->file_list.front().file_name.empty()) { if (ci->file_list.empty() || ci->file_list.front().file_name.empty()) {
return; // bad file return; // bad file
} }
total_size = ci->total_size; total_size = ci->total_size;
return; // TODO: figure out a collection strategy
} }
//const auto& file_info = h.get<Message::Components::Transfer::FileInfo>(); //const auto& file_info = h.get<Message::Components::Transfer::FileInfo>();