mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Allow to cancel dir size calculation (#13134)
This commit is contained in:
parent
eeda958f33
commit
382a27cb2f
@ -1924,7 +1924,7 @@ bool fs::remove_all(const std::string& path, bool remove_root, bool is_no_dir_ok
|
||||
return true;
|
||||
}
|
||||
|
||||
u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment)
|
||||
u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment, atomic_t<bool>* cancel_flag)
|
||||
{
|
||||
u64 result = 0;
|
||||
|
||||
@ -1937,6 +1937,11 @@ u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment)
|
||||
|
||||
for (const auto& entry : root_dir)
|
||||
{
|
||||
if (cancel_flag && *cancel_flag)
|
||||
{
|
||||
return umax;
|
||||
}
|
||||
|
||||
if (entry.name == "." || entry.name == "..")
|
||||
{
|
||||
continue;
|
||||
|
@ -669,7 +669,7 @@ namespace fs
|
||||
bool remove_all(const std::string& path, bool remove_root = true, bool is_no_dir_ok = false);
|
||||
|
||||
// Get size of all files recursively
|
||||
u64 get_dir_size(const std::string& path, u64 rounding_alignment = 1);
|
||||
u64 get_dir_size(const std::string& path, u64 rounding_alignment = 1, atomic_t<bool>* cancel_flag = nullptr);
|
||||
|
||||
enum class error : uint
|
||||
{
|
||||
|
@ -156,6 +156,13 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> gui_settings, std
|
||||
item->call_icon_func();
|
||||
}
|
||||
});
|
||||
connect(&m_size_watcher, &QFutureWatcher<void>::canceled, this, [this]()
|
||||
{
|
||||
if (m_size_watcher_cancel)
|
||||
{
|
||||
*m_size_watcher_cancel = true;
|
||||
}
|
||||
});
|
||||
connect(&m_size_watcher, &QFutureWatcher<void>::finished, this, [this]()
|
||||
{
|
||||
Refresh();
|
||||
@ -779,9 +786,11 @@ void game_list_frame::OnRefreshFinished()
|
||||
|
||||
Refresh();
|
||||
|
||||
m_size_watcher.setFuture(QtConcurrent::map(m_game_data, [this](const game_info& game) -> void
|
||||
m_size_watcher_cancel = std::make_shared<atomic_t<bool>>(false);
|
||||
|
||||
m_size_watcher.setFuture(QtConcurrent::map(m_game_data, [this, cancel = m_size_watcher_cancel](const game_info& game) -> void
|
||||
{
|
||||
if (game) game->info.size_on_disk = fs::get_dir_size(game->info.path);
|
||||
if (game) game->info.size_on_disk = fs::get_dir_size(game->info.path, 1, cancel.get());
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,7 @@ private:
|
||||
QFutureWatcher<void> m_size_watcher;
|
||||
QFutureWatcher<void> m_refresh_watcher;
|
||||
QFutureWatcher<movie_item*> m_repaint_watcher;
|
||||
std::shared_ptr<atomic_t<bool>> m_size_watcher_cancel;
|
||||
QSet<QString> m_hidden_list;
|
||||
bool m_show_hidden{false};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user