Pinning a file should automatically initiate a download to cache #38
This commit is contained in:
@@ -158,22 +158,26 @@ auto file_manager::download_pinned_file(const std::string &api_path) -> bool {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (provider_.is_read_only()) {
|
if (provider_.is_read_only()) {
|
||||||
|
// TODO handle error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string str_pinned;
|
std::string str_pinned;
|
||||||
auto res = provider_.get_item_meta(api_path, META_PINNED, str_pinned);
|
auto res = provider_.get_item_meta(api_path, META_PINNED, str_pinned);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
|
// TODO handle error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (not utils::string::to_bool(str_pinned)) {
|
if (not utils::string::to_bool(str_pinned)) {
|
||||||
|
// TODO handle error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto handle{static_cast<std::uint64_t>(REPERTORY_INVALID_HANDLE)};
|
std::uint64_t handle{};
|
||||||
std::shared_ptr<i_open_file> open_file;
|
std::shared_ptr<i_open_file> open_file;
|
||||||
res = open(api_path, false, {}, handle, open_file);
|
res = open(api_path, false, {}, handle, open_file);
|
||||||
if (res != api_error::success) {
|
if (res != api_error::success) {
|
||||||
|
// TODO handle error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +186,8 @@ auto file_manager::download_pinned_file(const std::string &api_path) -> bool {
|
|||||||
open_file->force_download();
|
open_file->force_download();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO handle error (ret == false)
|
||||||
|
|
||||||
close(handle);
|
close(handle);
|
||||||
return ret;
|
return ret;
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
|
Reference in New Issue
Block a user