Pinning a file should automatically initiate a download to cache #38

This commit is contained in:
2025-09-12 11:54:51 -05:00
parent b5fe6709d4
commit f0e1cc7fc5

View File

@@ -158,22 +158,26 @@ auto file_manager::download_pinned_file(const std::string &api_path) -> bool {
try {
if (provider_.is_read_only()) {
// TODO handle error
return false;
}
std::string str_pinned;
auto res = provider_.get_item_meta(api_path, META_PINNED, str_pinned);
if (res != api_error::success) {
// TODO handle error
return false;
}
if (not utils::string::to_bool(str_pinned)) {
// TODO handle error
return false;
}
auto handle{static_cast<std::uint64_t>(REPERTORY_INVALID_HANDLE)};
std::uint64_t handle{};
std::shared_ptr<i_open_file> open_file;
res = open(api_path, false, {}, handle, open_file);
if (res != api_error::success) {
// TODO handle error
return false;
}
@@ -182,6 +186,8 @@ auto file_manager::download_pinned_file(const std::string &api_path) -> bool {
open_file->force_download();
}
// TODO handle error (ret == false)
close(handle);
return ret;
} catch (const std::exception &ex) {