mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Reduce update rate in the "Directory scanning" dialog.
As a result, directory scannig is faster than before. The author of idea and initial patch is Egmont Koblinger. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
81201b3022
commit
c31e413b2a
@ -1515,7 +1515,7 @@ single_dirsize_cmd (void)
|
|||||||
p = vfs_path_from_str (entry->fname);
|
p = vfs_path_from_str (entry->fname);
|
||||||
|
|
||||||
memset (&dsm, 0, sizeof (dsm));
|
memset (&dsm, 0, sizeof (dsm));
|
||||||
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 1.0, dirsize_status_init_cb,
|
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 0, dirsize_status_init_cb,
|
||||||
dirsize_status_update_cb, dirsize_status_deinit_cb);
|
dirsize_status_update_cb, dirsize_status_deinit_cb);
|
||||||
|
|
||||||
if (compute_dir_size (p, &dsm, &dir_count, &count, &total, TRUE) == FILE_CONT)
|
if (compute_dir_size (p, &dsm, &dir_count, &count, &total, TRUE) == FILE_CONT)
|
||||||
@ -1550,7 +1550,7 @@ dirsizes_cmd (void)
|
|||||||
dirsize_status_msg_t dsm;
|
dirsize_status_msg_t dsm;
|
||||||
|
|
||||||
memset (&dsm, 0, sizeof (dsm));
|
memset (&dsm, 0, sizeof (dsm));
|
||||||
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 1.0, dirsize_status_init_cb,
|
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 0, dirsize_status_init_cb,
|
||||||
dirsize_status_update_cb, dirsize_status_deinit_cb);
|
dirsize_status_update_cb, dirsize_status_deinit_cb);
|
||||||
|
|
||||||
for (i = 0; i < panel->dir.len; i++)
|
for (i = 0; i < panel->dir.len; i++)
|
||||||
|
@ -521,7 +521,9 @@ do_compute_dir_size (const vfs_path_t * dirname_vpath, dirsize_status_msg_t * ds
|
|||||||
size_t * dir_count, size_t * ret_marked, uintmax_t * ret_total,
|
size_t * dir_count, size_t * ret_marked, uintmax_t * ret_total,
|
||||||
gboolean compute_symlinks)
|
gboolean compute_symlinks)
|
||||||
{
|
{
|
||||||
static unsigned short int update_ui_count = 0;
|
static guint64 timestamp = 0;
|
||||||
|
/* update with 25 FPS rate */
|
||||||
|
static const guint64 delay = G_USEC_PER_SEC / 25;
|
||||||
|
|
||||||
status_msg_t *sm = STATUS_MSG (dsm);
|
status_msg_t *sm = STATUS_MSG (dsm);
|
||||||
int res;
|
int res;
|
||||||
@ -564,36 +566,23 @@ do_compute_dir_size (const vfs_path_t * dirname_vpath, dirsize_status_msg_t * ds
|
|||||||
if (res == 0)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
if (S_ISDIR (s.st_mode))
|
if (S_ISDIR (s.st_mode))
|
||||||
{
|
|
||||||
ret =
|
ret =
|
||||||
do_compute_dir_size (tmp_vpath, dsm, dir_count, ret_marked, ret_total,
|
do_compute_dir_size (tmp_vpath, dsm, dir_count, ret_marked, ret_total,
|
||||||
compute_symlinks);
|
compute_symlinks);
|
||||||
if (ret == FILE_CONT && sm->update != NULL)
|
|
||||||
{
|
|
||||||
dsm->dirname_vpath = tmp_vpath;
|
|
||||||
dsm->dir_count = *dir_count;
|
|
||||||
dsm->total_size = *ret_total;
|
|
||||||
ret = (FileProgressStatus) sm->update (sm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ret = FILE_CONT;
|
||||||
|
|
||||||
(*ret_marked)++;
|
(*ret_marked)++;
|
||||||
*ret_total += (uintmax_t) s.st_size;
|
*ret_total += (uintmax_t) s.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
update_ui_count++;
|
if (ret == FILE_CONT && sm->update != NULL && mc_time_elapsed (×tamp, delay))
|
||||||
if ((update_ui_count & 31) == 0)
|
{
|
||||||
{
|
dsm->dirname_vpath = tmp_vpath;
|
||||||
if (sm->update == NULL)
|
dsm->dir_count = *dir_count;
|
||||||
ret = FILE_CONT;
|
dsm->total_size = *ret_total;
|
||||||
else
|
ret = (FileProgressStatus) sm->update (sm);
|
||||||
{
|
|
||||||
dsm->dirname_vpath = dirname_vpath;
|
|
||||||
dsm->dir_count = *dir_count;
|
|
||||||
dsm->total_size = *ret_total;
|
|
||||||
ret = (FileProgressStatus) sm->update (sm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1341,7 +1330,7 @@ panel_operate_init_totals (const WPanel * panel, const char *source, file_op_con
|
|||||||
|
|
||||||
memset (&dsm, 0, sizeof (dsm));
|
memset (&dsm, 0, sizeof (dsm));
|
||||||
dsm.allow_skip = TRUE;
|
dsm.allow_skip = TRUE;
|
||||||
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 1.0, dirsize_status_init_cb,
|
status_msg_init (STATUS_MSG (&dsm), _("Directory scanning"), 0, dirsize_status_init_cb,
|
||||||
dirsize_status_update_cb, dirsize_status_deinit_cb);
|
dirsize_status_update_cb, dirsize_status_deinit_cb);
|
||||||
|
|
||||||
ctx->progress_count = 0;
|
ctx->progress_count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user