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;
|
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) {
|
if (res != api_error::success) {
|
||||||
return false;
|
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::uint64_t handle{REPERTORY_INVALID_HANDLE};
|
||||||
std::shared_ptr<i_open_file> open_file;
|
std::shared_ptr<i_open_file> open_file;
|
||||||
if (open_file_lookup_.contains(api_path)) {
|
res = open(api_path, false, {}, handle, open_file);
|
||||||
auto closeable_file = open_file_lookup_.at(api_path);
|
if (res != api_error::success) {
|
||||||
if (not get_open_file(closeable_file->get_handles().at(0U), true,
|
return false;
|
||||||
open_file)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res = open(api_path, false, {}, handle);
|
|
||||||
if (res != api_error::success) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not get_open_file(handle, true, open_file)) {
|
|
||||||
close(handle);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open_file.download();
|
auto ret = get_open_file(handle, true, open_file);
|
||||||
if (handle != REPERTORY_INVALID_HANDLE) {
|
if (ret) {
|
||||||
close(handle);
|
open_file->download();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
close(handle);
|
||||||
|
return ret;
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
utils::error::raise_api_path_error(function_name, api_path, ex,
|
utils::error::raise_api_path_error(function_name, api_path, ex,
|
||||||
"failed to download pinned file");
|
"failed to download pinned file");
|
||||||
@@ -1005,7 +994,7 @@ void file_manager::start() {
|
|||||||
: 0U,
|
: 0U,
|
||||||
fsi, provider_, entry.read_state, *this);
|
fsi, provider_, entry.read_state, *this);
|
||||||
open_file_lookup_[entry.api_path] = closeable_file;
|
open_file_lookup_[entry.api_path] = closeable_file;
|
||||||
closeable_file.download();
|
closeable_file->download();
|
||||||
|
|
||||||
event_system::instance().raise<download_restored>(
|
event_system::instance().raise<download_restored>(
|
||||||
fsi.api_path, fsi.source_path, function_name);
|
fsi.api_path, fsi.source_path, function_name);
|
||||||
|
@@ -151,8 +151,7 @@ public:
|
|||||||
(override));
|
(override));
|
||||||
|
|
||||||
MOCK_METHOD(api_error, set_item_meta,
|
MOCK_METHOD(api_error, set_item_meta,
|
||||||
(const std::string &api_path, const api_meta_map &meta),
|
(const std::string &api_path, api_meta_map meta), (override));
|
||||||
(override));
|
|
||||||
|
|
||||||
MOCK_METHOD(bool, start,
|
MOCK_METHOD(bool, start,
|
||||||
(api_item_added_callback api_item_added, i_file_manager *fm),
|
(api_item_added_callback api_item_added, i_file_manager *fm),
|
||||||
|
Reference in New Issue
Block a user