diff --git a/src/command_download.cc b/src/command_download.cc index 0d651b20..908c4cbe 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -843,7 +843,7 @@ initialize_command_download() { 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.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_bytes", CMD2_ON_FL(size_bytes)); diff --git a/src/command_events.cc b/src/command_events.cc index 0d594bd4..7e3d0388 100644 --- a/src/command_events.cc +++ b/src/command_events.cc @@ -168,12 +168,14 @@ torrent::Object apply_close_low_diskspace(int64_t arg, uint32_t skip_priority) { bool closed = false; + torrent::FileList::cache_list cache; + for (auto download : *control->core()->download_list()) { if (!download->is_downloading()) continue; if (download->priority() >= skip_priority) continue; - if (download->file_list()->free_diskspace() >= (uint64_t)arg) + if (download->file_list()->free_diskspace(cache) >= (uint64_t)arg) continue; control->core()->download_list()->close(download); diff --git a/src/rpc/command.h b/src/rpc/command.h index d177da9c..a4aa6acb 100644 --- a/src/rpc/command.h +++ b/src/rpc/command.h @@ -169,9 +169,11 @@ public: template void set_function(T s, [[maybe_unused]] int value = command_base_is_valid::value) { 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));