Commit Graph

6624 Commits

Author SHA1 Message Date
Andrew Borodin
5047d4d114 Calculate pauses in file operations.
Calculate BPS and ETA, taking into account pauses due to query
dialog boxes.

  * (file_op_context_t): new 'pauses' member.
  * (file_error): pass file operation context to calculate pause.
  * (real_warn_same_file): likewise.
  * (real_do_file_error): likewise.
  * (real_query_recursive): calculate pause.
  * (overwrite_query_dialog): likewise.
  * (file_progress_show_total): use ctx->pauses to show time of
    operation.
  * (calc_copy_file_progress): calculate use ctx->pauses to calculate ETA.
  * (warn_same_file):
  * (check_same_file):
  * (check_hardlinks):
  * (make_symlink):
  * (do_file_error):
  * (files_error):
  * (try_remove_file):
  * (move_file_file):
  * (try_erase_dir):
  * (do_move_dir_dir):
  * (copy_file_file):
  * (copy_dir_dir):
  * (panel_operate):
  * (tree_move): related changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:01 +03:00
Andrew Borodin
1e35ae3adb File copy/move: make ETA accurate.
* (progress_update_one): update total progress bytes counter. Update
    progress info in the progress window only if file was processed
    successfully. Don't check buttons here.
  * (move_file_file): update progress info if file move wasn't aborted.
  * (copy_file_file): update progress info if stat() or open() failed
    (file size is unknown, but file counter shoud be updated). Modify
    caclulation and display of byte counters.
  * (panel_operate): simplify files processing loop. Remove action that
    already done via operate_one_file() call.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:01 +03:00
Andrew Borodin
ff1a404bb3 (calc_copy_file_progress): clarify calculation of BPSes and ETAs.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:01 +03:00
Andrew Borodin
07ea52d767 (panel_operate): use intermediate variable for better indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:00 +03:00
Andrew Borodin
e2ca50418d (copy_file_file): clarify handling of mc_open() errors.
Handle mc_open() errors in the same way as mc_fstat().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:00 +03:00
Andrew Borodin
25fb677b87 (copy_file_file): fix handling of mc_open() error.
In case of FILE_IGNORE, immediately stop processing of file.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:38:00 +03:00
Andrew Borodin
e6e329bc8c (calc_copy_file_progress): rename from copy_file_file_display_progress().
Refactoring, reuse variable.

(file_op_context_t): remove 'bps_time' member. It's unused anymore.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
d844c6212c (file_progress_show_total): add 'tv_current' argument.
Get rid of g_get_monotonic_time() here. If possible, use time value
calculated before.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
6ba3cc68c0 (file_progress_show_total): use 'copied_bytes' to show numeric value.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
2b1a63aef3 (file_progress_show_count): remove 'done' and 'total' arguments.
Use members of 'ctx' instead.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
7c418111fd (erase_dir_iff_empty): remove 'count' argument.
Use 'ctx->progress_count' instead.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
527cb1424d (file_op_context_t): rename members.
copied_bytes -> total_progress_bytes
progress_count -> total_progress_count
prev_progress_count -> prev_total_progress_count

No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
debd1ee8ce (copy_file_file): reduce variable scope, change order of progress update.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
64c6de4ab8 (file_op_context_t): reorder members.
No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-13 19:37:59 +03:00
Andrew Borodin
17fd844315 Move content of src/filemanager/fileopctx.[ch] to src/filemanager/filegui.[ch].
No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
b2b10f1f87 (file_op_total_context_t): remove. All members were moved to file_op_context_t.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
dde9002aaf (file_op_total_context_t): rename members.
bps -> total_bps
transfer_start -> total_transfer_start
eta_secs -> total_eta_secs

No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
ab5bbba2dd (copy_file_file_display_progress): remove dead code.
(file_op_total_context_t): bps_count member is unused. Remove it.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
23ed903814 (file_op_context_t): rename members.
progress_count -> total_count
progress_bytes -> total_bytes
progress_totals_computed -> totals_computed

No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
31771bd332 Store start time of file transfer in the file operation context descriptor.
* (file_op_context_t): new member transfer_start.
  * (copy_file_file_display_progress): remove tv_transfer_start
    argument, use ctx->transfer_start instead.
  * (copy_file_file): sync with modified file_op_context_t and
    copy_file_file_display_progress().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
f699e184ea (file_op_context_new): simplify.
Don't NULLify members. This is already done by call of g_new0().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
a1b4eb0bfb Rename file_op_context_ui_t to file_progress_ui_t, reorder members.
No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
0a6604a626 Rename functions.
file_op_context_create_ui -> file_progress_ui_create
file_op_context_destroy_ui -> file_progress_ui_destroy
check_progress_buttons -> file_progress_check_buttons

No functional changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
63db380705 (copy_file_file_display_progress): change arguments order.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
6d3c41082c (copy_file_file): fix the ETA calculation.
Pass only the size of the remaining part of file to
copy_file_file_display_progress().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
bf9a279d1a (file_eta_prepare_for_show): join checks of eta_secs.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Andrew Borodin
f911cf30cb Ticket #3205: fix ETA calculation.
Check "verbose" before file_progress_show() call.

  * (file_progress_show): don't chech "verbose" here.
  * (move_file_file): call file_progress_show() if "verbose" is on.
  * (do_move_dir_dir): likewise.
  * (copy_file_file): likewise, join checks.
  * (panel_operate): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-11-05 18:19:28 +03:00
Yury V. Zaytsev
8b8419023f Ticket #2452: handle -1 (baudrate error) by *not* disabling verbose mode implicitly
If we can't reliably identify slow terminal, we should not implicitly disable
verbose mode, instead let user disable it manually by starting with the slow
terminal switch.

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-11-04 17:29:25 +01:00
Viorel Munteanu
18f0a28501 Ticket #4599: add support for bash PROMPT_COMMAND being an array
Starting with bash 5.1, PROMPT_COMMAND can be an array. Detect this
case and append an entry to the array instead of appending to a string.

Testing for bash >= 5 is sufficient, because the @a operator exists in
5.0. We need eval on the "then" branch because bash 1.x cannot even
parse that line (it does not support arrays).

Bug: https://bugs.gentoo.org/930401
Suggested-by: kfm@plushkava.net
Signed-off-by: Viorel Munteanu <ceamac@gentoo.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-11-01 19:26:04 +01:00
Johannes Altmanninger
6ca2013082 subshell: advertise that we can suspend a shell that requested CSI u
Add a new variable to let fish know that -- since the parent commit
-- we are running a version where fish can use the kitty keyboard
protocol without breaking mc.

In a few years, both fish and mc should ideally remove this hack
(and fish should speak the kitty keyboard protocol unconditionally),
so no one should rely on this new variable except as a temporary
workaround. Hence the feature-specific flag and not a generic version
variable.

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-11-01 18:34:18 +01:00
Johannes Altmanninger
6e4510b558 subshell: recognize CSI u encoding for ctrl-o
If a subshell (like fish 4.0) wishes to use "Disambiguate control keys"
from https://sw.kovidgoyal.net/kitty/keyboard-protocol/, ctrl-o sends
a multi-byte sequence.  Let's make sure we can intercept that too so
we can suspend the shell.

Note that the shell already disables "Disambiguate control keys"
while it's suspended, so no other changes should be necessary.

Unfortunately there is one bug left: when I start "SHELL=$(which
fish) mc" and type `ctrl-o`, fish does not recognize CSI u bindings
(such as `bind ctrl-2 'echo hello'`) yet.  It only works after the
second prompt.  I haven't had time to figure that out.

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-11-01 18:34:18 +01:00
Yury V. Zaytsev
61909fa24e mountlist: suppress unused label warning on FreeBSD
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-11-01 17:37:10 +01:00
Yury V. Zaytsev
6881db8b16 posix: use tail -1, not tail -n 1, prefer gsed for Solaris compat
Non-XPG4 version of `tail` fails if you call it as `tail -n 1`, but `tail -1`
works everywhere and is portable.

```
% ssh solaris
Last login: Sun Oct 20 12:20:56 2024 from 192.168.64.1
Oracle Solaris 11.4.42.111.0                  Assembled December 2021
root@solaris:~# tail -n 1 .profile
usage: tail [+/-[n][lbc][f]] [file]
       tail [+/-[n][l][r|f]] [file]
root@solaris:~# tail -1 .profile

root@solaris:~# head -n 1 .profile
root@solaris:~# head -1 .profile
root@solaris:~# /usr/xpg4/bin/tail -n 1 .profile
```

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-26 18:22:53 +02:00
Yury V. Zaytsev
9182a89922 filemanager: remove duplicate include header
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-20 20:38:29 +02:00
Andrew Borodin
b232229b46 src/filemanager/{achown,chattr,chmod,chown}.c: get rid of code duplication.
* (panel_find_marked_file):
  * (panel_get_marked_file): new WPanel APIs.
  * Use these APIs in src/filemanager/{achown,chattr,chmod,chown}.c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-19 20:45:22 +03:00
Andrew Borodin
2d9383fd54 (panel_callback) [MSG_FOCUS]: remove self-draw here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-19 20:02:59 +03:00
Andrew Borodin
b14f778e6b Disable all cursor movements if file panel is empty.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-19 20:02:59 +03:00
Andrew Borodin
562eb7449a (start_search): don't start quick search if file panel is empty.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-19 11:40:36 +03:00
Andrew Borodin
f147c8b3e2 Clarify panel->currrent if file panel is empty.
* (panel_do_cd_int): set panel->current to -1 file list is empty.
  * (panel_set_current_by_name): likewise.
  * (panel_sized_with_dir_new): likewise.
  * (panel_reload): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-19 11:40:36 +03:00
Andrew Borodin
1ac839d20c Ticket #4600: fix segfault on panel filter.
mc segfaults if filter makes file panel empty.

  * (panel_current_entry): improve. Add checks if panel->current is in
  range of file list.
  * A lot of changes to use modified panel_current_entry().
  * (format_file):
  * (display_mini_info): fix drawing of mini-status if file panel is
  empty.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-19 11:38:31 +03:00
Yury V. Zaytsev
6c5cf214a9 extfs: use numeric (0/0) root user uid/gid in helpers instead of root/root
Non-Linux systems don't always name the user and group with uid/gid of 0
"root". On macOS group "wheel" has gid of 0 and group "root" doesn't exist. On
FreeBSD there is a user with gid of 0 named "toor". This causes user/group id
lookups in mc to fail and instead return the uid/gid of the current user.

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-19 08:56:56 +02:00
Yury V. Zaytsev
93b539444b Ticket #4584: re-implement mocking via weak symbols instead of symbol duplication
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-19 08:56:40 +02:00
Yury V. Zaytsev
09320d5381 (attrs_ignore_error): constify input param and fix typos
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-19 08:52:28 +02:00
Yury V. Zaytsev
a3a6d00a61 cmd: remove forgotten mmap macros and includes
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-19 08:49:49 +02:00
Andrew Borodin
1f36a3fd80 (copy_dir_dir): clarify get of mode and attributes of source directory.
Use the same way as in copy_file_file().

Signed-off-by: Andrew Borodin <borodin@axion.lan>
2024-10-18 18:37:40 +03:00
Andrew Borodin
5486bdad0e file operations: rename actions and button names:
skip -> ignore
skip all -> ignore all.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-18 18:37:40 +03:00
Andrew Borodin
cbb3c9a372 Clarify messages of get/set ext2 attributes errors.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-10-18 18:37:39 +03:00
Andrew Borodin
5f5e71b7f8 Ticket #4590: clarify handling of ext2 attributes errors.
Don't show an error message if mc_fgetflags() and mc_fsetflags()
fails and errno set to ENOTSUP, EOPNOTSUPP, ENOSYS, and EINVAL.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-18 18:37:39 +03:00
Andrew Borodin
de7d72cab4 src/vfs/tar/tar-internal.c: define UINTMAX_WIDTH.
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-17 21:10:08 +02:00
Andrew Borodin
0c505b9e13 tar: initialize variables passed to stoint().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2024-10-10 21:16:32 +03:00