Enabling progress for Git checkout

This commit is contained in:
Matthias Koefferlein 2023-10-29 22:22:53 +01:00
parent a4df1eb10f
commit 9b969c25be
3 changed files with 30 additions and 5 deletions

View File

@ -143,7 +143,7 @@ SaltController::show_editor ()
{
// while running the dialog, don't watch file events - that would interfere with
// the changes applied by the dialog itself.
lay::BusySection busy_section; // disable file watcher
tl::FileSystemWatcherDisabled disable_file_watcher; // disable file watcher
mp_salt_dialog->exec ();
}
@ -157,7 +157,7 @@ SaltController::show_editor ()
void
SaltController::sync_file_watcher ()
{
lay::BusySection busy_section; // disable file watcher
tl::FileSystemWatcherDisabled disable_file_watcher; // disable file watcher
if (m_file_watcher) {
m_file_watcher->clear ();
@ -231,7 +231,7 @@ SaltController::install_packages (const std::vector<std::string> &packages, bool
{
// while running the dialog, don't watch file events - that would interfere with
// the changes applied by the dialog itself.
lay::BusySection busy_section; // disable file watcher
tl::FileSystemWatcherDisabled disable_file_watcher; // disable file watcher
result = manager.execute (0, m_salt);
}

View File

@ -140,6 +140,23 @@ private:
std::map<std::string, FileEntry>::iterator m_iter;
};
/**
* @brief A class employing RIIA for locking the file system watcher
*/
class TL_PUBLIC FileSystemWatcherDisabled
{
public:
FileSystemWatcherDisabled ()
{
tl::FileSystemWatcher::global_enable (false);
}
~FileSystemWatcherDisabled ()
{
tl::FileSystemWatcher::global_enable (true);
}
};
}
#endif

View File

@ -116,7 +116,11 @@ fetch_progress (const git_transfer_progress *stats, void *payload)
// first half of progress
size_t count = size_t (5000.0 * double (stats->received_objects) / double (std::max (1u, stats->total_objects)) + 1e-10);
progress->set (count);
try {
progress->set (count);
} catch (...) {
// TODO: stop
}
return 0;
}
@ -128,7 +132,11 @@ checkout_progress(const char * /*path*/, size_t cur, size_t tot, void *payload)
// first half of progress
size_t count = size_t (5000.0 * double (cur) / double (std::max (size_t (1), tot)) + 1e-10);
progress->set (count + 5000u);
try {
progress->set (count + 5000u);
} catch (...) {
// ignore cancel requests (TODO: how to stop?)
}
}
static void check (int error)