Pinning a file should automatically initiate a download to cache #38
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -161,7 +161,8 @@ auto file_manager::download_pinned_file(const std::string &api_path) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto res = provider_.get_file_meta(api_path, META_PINNED, str_pinned);
|
||||
std::string str_pinned;
|
||||
auto res = provider_.get_item_meta(api_path, META_PINNED, str_pinned);
|
||||
if (res != api_error::success) {
|
||||
return false;
|
||||
}
|
||||
@@ -171,30 +172,18 @@ auto file_manager::download_pinned_file(const std::string &api_path) -> bool {
|
||||
|
||||
std::uint64_t handle{REPERTORY_INVALID_HANDLE};
|
||||
std::shared_ptr<i_open_file> open_file;
|
||||
if (open_file_lookup_.contains(api_path)) {
|
||||
auto closeable_file = open_file_lookup_.at(api_path);
|
||||
if (not get_open_file(closeable_file->get_handles().at(0U), true,
|
||||
open_file)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
res = open(api_path, false, {}, handle);
|
||||
res = open(api_path, false, {}, handle, open_file);
|
||||
if (res != api_error::success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (not get_open_file(handle, true, open_file)) {
|
||||
close(handle);
|
||||
return false;
|
||||
}
|
||||
auto ret = get_open_file(handle, true, open_file);
|
||||
if (ret) {
|
||||
open_file->download();
|
||||
}
|
||||
|
||||
open_file.download();
|
||||
if (handle != REPERTORY_INVALID_HANDLE) {
|
||||
close(handle);
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
} catch (const std::exception &ex) {
|
||||
utils::error::raise_api_path_error(function_name, api_path, ex,
|
||||
"failed to download pinned file");
|
||||
@@ -1005,7 +994,7 @@ void file_manager::start() {
|
||||
: 0U,
|
||||
fsi, provider_, entry.read_state, *this);
|
||||
open_file_lookup_[entry.api_path] = closeable_file;
|
||||
closeable_file.download();
|
||||
closeable_file->download();
|
||||
|
||||
event_system::instance().raise<download_restored>(
|
||||
fsi.api_path, fsi.source_path, function_name);
|
||||
|
@@ -151,8 +151,7 @@ public:
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(api_error, set_item_meta,
|
||||
(const std::string &api_path, const api_meta_map &meta),
|
||||
(override));
|
||||
(const std::string &api_path, api_meta_map meta), (override));
|
||||
|
||||
MOCK_METHOD(bool, start,
|
||||
(api_item_added_callback api_item_added, i_file_manager *fm),
|
||||
|
Reference in New Issue
Block a user