Complete ring buffer and direct download support #26
This commit is contained in:
parent
924875d0b2
commit
49fa2e6637
@ -21,6 +21,7 @@
|
||||
* \#23 \[bug\] Incorrect file size displayed while upload is pending
|
||||
* \#24 RocksDB implementations should be transactional
|
||||
* \#25 Writes should block when maximum cache size is reached
|
||||
* \#26 Complete ring buffer and direct download support
|
||||
|
||||
### Changes from v2.0.1-rc
|
||||
|
||||
|
@ -44,6 +44,7 @@ using event_consumer = event_system::event_consumer;
|
||||
#define E_FROM_STRING(t) t
|
||||
#define E_FROM_UINT16(t) std::to_string(t)
|
||||
#define E_FROM_UINT64(t) std::to_string(t)
|
||||
#define E_FROM_DOWNLOAD_TYPE(t) download_type_to_string(t)
|
||||
|
||||
#define E_PROP(type, name, short_name, ts) \
|
||||
private: \
|
||||
|
@ -74,6 +74,12 @@ E_SIMPLE1(drive_unmounted, info, true,
|
||||
std::string, location, loc, E_FROM_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_type_selected, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, source, src, E_FROM_STRING,
|
||||
download_type, download_type, type, E_FROM_DOWNLOAD_TYPE
|
||||
);
|
||||
|
||||
E_SIMPLE1(event_level_changed, info, true,
|
||||
std::string, new_event_level, level, E_FROM_STRING
|
||||
);
|
||||
|
@ -104,12 +104,12 @@ void file_manager::close_timed_out_files() {
|
||||
}
|
||||
return items;
|
||||
});
|
||||
for (auto &&closeable_file : closeable_list) {
|
||||
for (const auto &closeable_file : closeable_list) {
|
||||
open_file_lookup_.erase(closeable_file->get_api_path());
|
||||
}
|
||||
file_lock.unlock();
|
||||
|
||||
for (auto &&closeable_file : closeable_list) {
|
||||
for (auto &closeable_file : closeable_list) {
|
||||
closeable_file->close();
|
||||
event_system::instance().raise<item_timeout>(
|
||||
closeable_file->get_api_path());
|
||||
@ -267,7 +267,7 @@ auto file_manager::get_open_files() const
|
||||
std::unordered_map<std::string, std::size_t> ret;
|
||||
|
||||
recur_mutex_lock open_lock(open_file_mtx_);
|
||||
for (auto &&item : open_file_lookup_) {
|
||||
for (const auto &item : open_file_lookup_) {
|
||||
ret[item.first] = item.second->get_open_file_count();
|
||||
}
|
||||
|
||||
@ -465,7 +465,11 @@ auto file_manager::open(
|
||||
auto chunk_timeout = config_.get_enable_download_timeout()
|
||||
? config_.get_download_timeout_secs()
|
||||
: 0U;
|
||||
switch (get_download_type(config_.get_preferred_download_type())) {
|
||||
auto type = get_download_type(config_.get_preferred_download_type());
|
||||
event_system::instance().raise<download_type_selected>(fsi.api_path,
|
||||
fsi.source_path);
|
||||
|
||||
switch (type) {
|
||||
case repertory::download_type::direct: {
|
||||
closeable_file = std::make_shared<direct_open_file>(
|
||||
chunk_size, chunk_timeout, fsi, provider_);
|
||||
@ -882,7 +886,7 @@ void file_manager::stop() {
|
||||
open_file_lookup_.clear();
|
||||
|
||||
upload_lock.lock();
|
||||
for (auto &&item : upload_lookup_) {
|
||||
for (auto &item : upload_lookup_) {
|
||||
item.second->stop();
|
||||
}
|
||||
upload_notify_.notify_all();
|
||||
|
@ -106,7 +106,7 @@ ring_buffer_open_file::~ring_buffer_open_file() {
|
||||
auto ring_buffer_open_file::can_handle_file(std::uint64_t file_size,
|
||||
std::size_t chunk_size,
|
||||
std::size_t ring_size) -> bool {
|
||||
return file_size <= (static_cast<std::uint64_t>(ring_size) * chunk_size);
|
||||
return file_size >= (static_cast<std::uint64_t>(ring_size) * chunk_size * 2U);
|
||||
}
|
||||
|
||||
auto ring_buffer_open_file::close() -> bool {
|
||||
|
Loading…
x
Reference in New Issue
Block a user