fixes
This commit is contained in:
@ -32,23 +32,6 @@ E_SIMPLE2(download_begin, info, true,
|
||||
std::string, dest_path, dest, E_FROM_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE5(download_chunk_begin, debug, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
std::size_t, chunk, chunk, E_FROM_SIZE_T,
|
||||
std::size_t, total, total, E_FROM_SIZE_T,
|
||||
std::size_t, complete, complete, E_FROM_SIZE_T
|
||||
);
|
||||
|
||||
E_SIMPLE6(download_chunk_end, debug, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
std::size_t, chunk, chunk, E_FROM_SIZE_T,
|
||||
std::size_t, total, total, E_FROM_SIZE_T,
|
||||
std::size_t, complete, complete, E_FROM_SIZE_T,
|
||||
api_error, result, result, E_FROM_API_FILE_ERROR
|
||||
);
|
||||
|
||||
E_SIMPLE3(download_end, info, true,
|
||||
std::string, api_path, ap, E_FROM_STRING,
|
||||
std::string, dest_path, dest, E_FROM_STRING,
|
||||
|
@ -149,17 +149,13 @@ auto direct_open_file::download_chunk(std::size_t chunk, bool skip_active)
|
||||
auto active_download{std::make_shared<download>()};
|
||||
active_downloads_[chunk] = active_download;
|
||||
ring_state_[chunk % ring_state_.size()] = false;
|
||||
unlock_and_notify();
|
||||
|
||||
auto &buffer = ring_data_.at(chunk % ring_state_.size());
|
||||
auto data_offset{chunk * chunk_size_};
|
||||
auto data_size{
|
||||
chunk == (total_chunks_ - 1U) ? last_chunk_size_ : chunk_size_,
|
||||
};
|
||||
|
||||
event_system::instance().raise<download_chunk_begin>(
|
||||
fsi_.api_path, "direct", chunk, get_read_state().size(),
|
||||
get_read_state().count());
|
||||
unlock_and_notify();
|
||||
|
||||
auto res{
|
||||
provider_.read_file_bytes(fsi_.api_path, data_size, data_offset, buffer,
|
||||
@ -173,12 +169,11 @@ auto direct_open_file::download_chunk(std::size_t chunk, bool skip_active)
|
||||
100.0;
|
||||
event_system::instance().raise<download_progress>(fsi_.api_path, "direct",
|
||||
progress);
|
||||
res = (chunk >= ring_begin_ && chunk <= ring_end_)
|
||||
? res
|
||||
: api_error::invalid_ring_buffer_position;
|
||||
}
|
||||
|
||||
event_system::instance().raise<download_chunk_end>(
|
||||
fsi_.api_path, "direct", chunk, get_read_state().size(),
|
||||
get_read_state().count(), res);
|
||||
|
||||
active_downloads_.erase(chunk);
|
||||
unlock_and_notify();
|
||||
|
||||
@ -303,9 +298,9 @@ auto direct_open_file::read(std::size_t read_size, std::uint64_t read_offset,
|
||||
read_size),
|
||||
};
|
||||
|
||||
auto &source_buffer = ring_data_.at(chunk % ring_state_.size());
|
||||
auto begin = std::next(source_buffer.begin(),
|
||||
static_cast<std::int64_t>(read_offset));
|
||||
auto &buffer = ring_data_.at(chunk % ring_state_.size());
|
||||
auto begin =
|
||||
std::next(buffer.begin(), static_cast<std::int64_t>(read_offset));
|
||||
auto end = std::next(begin, static_cast<std::int64_t>(to_read));
|
||||
data.insert(data.end(), begin, end);
|
||||
|
||||
|
@ -300,9 +300,6 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
||||
event_system::instance().raise<download_begin>(fsi_.api_path,
|
||||
fsi_.source_path);
|
||||
}
|
||||
event_system::instance().raise<download_chunk_begin>(
|
||||
fsi_.api_path, fsi_.source_path, chunk, read_state.size(),
|
||||
read_state.count());
|
||||
|
||||
active_downloads_[chunk] = std::make_shared<download>();
|
||||
rw_lock.unlock();
|
||||
@ -319,9 +316,6 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
||||
unique_recur_mutex_lock lock(rw_mtx_);
|
||||
auto active_download = active_downloads_.at(chunk);
|
||||
active_downloads_.erase(chunk);
|
||||
event_system::instance().raise<download_chunk_end>(
|
||||
fsi_.api_path, fsi_.source_path, chunk, state.size(), state.count(),
|
||||
get_api_error());
|
||||
if (get_api_error() == api_error::success) {
|
||||
auto progress = (static_cast<double>(state.count()) /
|
||||
static_cast<double>(state.size())) *
|
||||
|
@ -202,10 +202,6 @@ auto ring_buffer_open_file::download_chunk(std::size_t chunk, bool skip_active)
|
||||
chunk == (total_chunks_ - 1U) ? last_chunk_size_ : chunk_size_,
|
||||
};
|
||||
|
||||
event_system::instance().raise<download_chunk_begin>(
|
||||
fsi_.api_path, source_path_, chunk, get_read_state().size(),
|
||||
get_read_state().count());
|
||||
|
||||
auto res{
|
||||
provider_.read_file_bytes(fsi_.api_path, data_size, data_offset, buffer,
|
||||
stop_requested_),
|
||||
@ -232,10 +228,6 @@ auto ring_buffer_open_file::download_chunk(std::size_t chunk, bool skip_active)
|
||||
: api_error::invalid_ring_buffer_position;
|
||||
}
|
||||
|
||||
event_system::instance().raise<download_chunk_end>(
|
||||
fsi_.api_path, source_path_, chunk, get_read_state().size(),
|
||||
get_read_state().count(), res);
|
||||
|
||||
active_downloads_.erase(chunk);
|
||||
unlock_and_notify();
|
||||
|
||||
|
Reference in New Issue
Block a user