Use a cache for free diskspace when sync'ing all downloads.

This commit is contained in:
Jari Sundell
2026-06-18 16:45:55 +02:00
committed by GitHub
parent bf74686c29
commit acb02379b8
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -843,7 +843,7 @@ initialize_command_download() {
CMD2_DL ("d.bytes_done", CMD2_ON_DL(bytes_done)); CMD2_DL ("d.bytes_done", CMD2_ON_DL(bytes_done));
CMD2_DL ("d.ratio", std::bind(&retrieve_d_ratio, std::placeholders::_1)); CMD2_DL ("d.ratio", std::bind(&retrieve_d_ratio, std::placeholders::_1));
CMD2_DL ("d.chunks_hashed", CMD2_ON_DL(chunks_hashed)); CMD2_DL ("d.chunks_hashed", CMD2_ON_DL(chunks_hashed));
CMD2_DL ("d.free_diskspace", CMD2_ON_FL(free_diskspace)); CMD2_DL ("d.free_diskspace", [](auto* download, auto) { return download->file_list()->free_diskspace_no_cache(); });
CMD2_DL ("d.size_files", CMD2_ON_FL(size_files)); CMD2_DL ("d.size_files", CMD2_ON_FL(size_files));
CMD2_DL ("d.size_bytes", CMD2_ON_FL(size_bytes)); CMD2_DL ("d.size_bytes", CMD2_ON_FL(size_bytes));
+3 -1
View File
@@ -168,12 +168,14 @@ torrent::Object
apply_close_low_diskspace(int64_t arg, uint32_t skip_priority) { apply_close_low_diskspace(int64_t arg, uint32_t skip_priority) {
bool closed = false; bool closed = false;
torrent::FileList::cache_list cache;
for (auto download : *control->core()->download_list()) { for (auto download : *control->core()->download_list()) {
if (!download->is_downloading()) if (!download->is_downloading())
continue; continue;
if (download->priority() >= skip_priority) if (download->priority() >= skip_priority)
continue; continue;
if (download->file_list()->free_diskspace() >= (uint64_t)arg) if (download->file_list()->free_diskspace(cache) >= (uint64_t)arg)
continue; continue;
control->core()->download_list()->close(download); control->core()->download_list()->close(download);
+4 -2
View File
@@ -169,9 +169,11 @@ public:
template <typename T> template <typename T>
void set_function(T s, [[maybe_unused]] int value = command_base_is_valid<T>::value) { void set_function(T s, [[maybe_unused]] int value = command_base_is_valid<T>::value) {
static_assert(sizeof(T) <= sizeof(t_pod), "t_pod storage overflow"); static_assert(sizeof(T) <= sizeof(t_pod), "t_pod storage overflow");
static_assert(alignof(t_pod) % alignof(T) == 0, "t_pod alignment violation"); static_assert(alignof(std::max_align_t) % alignof(T) == 0, "t_pod alignment insufficient for type");
static_assert(alignof(std::max_align_t) >= alignof(T), "t_pod structural capacity mismatch");
if (m_dest_helper) m_dest_helper(t_pod); if (m_dest_helper)
m_dest_helper(t_pod);
::new (t_pod) T(std::move(s)); ::new (t_pod) T(std::move(s));