[Midnight Commander] #4279: FISH download, file modification and access times truncated

0 views
Skip to first unread message

Ticket System

unread,
Sep 3, 2021, 7:40:09 AM9/3/21
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------------+------------------------------
Reporter: opty | Type: defect
Status: new | Priority: major
Milestone: Future Releases | Component: mc-vfs
Version: 4.8.27 | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------------+------------------------------
When downloading a file using FISH, it doesn't preserve (nano)seconds and
even the whole time when copying from !OpenWrt 19.07.7. Should FISH use
''ls --full-time''?

Workaround: Use upload (if possible).

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279>
Midnight Commander <https://midnight-commander.org>
Midnight Development Center

Ticket System

unread,
Sep 4, 2021, 5:15:53 PM9/4/21
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by opty):

''ls --full-time'' without Perl (like !OpenWrt), ''%S'' in ''strftime()''
with Perl and ''D'' instead of ''d'' in both.

Unfortunately, Perl's nanoseconds support through Time::!HiRes seems
problematic (floating point representation), so prefer ls over Perl?

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:1>

Ticket System

unread,
Sep 12, 2021, 9:24:03 AM9/12/21
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by opty):

Trying to use ''%S'' with ''D'' in Perl leads to timezone (DST in my case)
problem due to ''mktime(3)'' in C but just adding '':%S'' to
''strftime()'' and keeping the ''d'' seems to work.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:2>

Ticket System

unread,
Sep 14, 2021, 10:50:47 AM9/14/21
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by opty):

So far (seconds):


{{{
#!diff
--- old/usr/libexec/mc/fish/ls 2018-06-05 05:12:34.000000000 +0000
+++ new/usr/libexec/mc/fish/ls 2021-09-14 14:00:11.706049876 +0000
@@ -5,21 +5,21 @@
fish_list_lsq ()
{
FISH_DIR="$1"
-ls -Qlan "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | (
-while read p l u g s m d y n; do
+ls -Qan --full-time "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | (
+while read p l u g s d t z n; do
echo "P$p $u.$g"
echo "S$s"
- echo "d$m $d $y"
+ echo "d${d#*-}-${d%%-*} ${t%.*}"
echo ":$n"
echo
done
)

-ls -Qlan "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | (
-while read p l u g a i m d y n; do
+ls -Qan --full-time "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | (
+while read p l u g a i d t z n; do
echo "P$p $u.$g"
echo "E$a$i"
- echo "d$m $d $y"
+ echo "d${d#*-}-${d%%-*} ${t%.*}"
echo ":$n"
echo
done
@@ -130,7 +130,7 @@
if (opendir (DIR, $dirname)) {
while((my $filename = readdir (DIR))){
my
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)
= lstat("$dirname/$filename");
- my $mloctime= strftime("%m-%d-%Y %H:%M", localtime $mtime);
+ my $mloctime= strftime("%m-%d-%Y %H:%M:%S", localtime $mtime);
my $strutils_shell_escape_regex =
s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'\''"\ \\])/\\$1/g;
my $e_filename = $filename;
$e_filename =~ $strutils_shell_escape_regex;
}}}

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:3>

Ticket System

unread,
Sep 14, 2021, 2:37:05 PM9/14/21
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by andrew_b):

`ls --full-time` is not portable. GNU ls has this option, but BSD hasn't.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:4>

Ticket System

unread,
Sep 15, 2021, 6:48:54 AM9/15/21
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by zaytsev):

Well, BSD doesn't seem to have `-Q` either - on my Mac:

{{{
zaytsev@Yurys-MBP ~ % ls -Qlan
ls: illegal option -- Q
usage: ls [-@ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1%] [file ...]
}}}

BSD has `-T` though, which shows at least seconds, but GNU uses it for
something else :-(

I think that the helpers are named in a very confusing way:

* `fish_list_lsq` should be probably called `fish_list_gnu`
* `fish_list_sed` should be probably called `fish_list_bsd`
* `fish_list_poor_ls` should be probably called `fish_list_busybox`

This way the logic is more clear - Perl is used for maximal portability
wherever it's available to ensure consistent results - otherwise use plain
`ls` and POSIX stuff for three major userland types... At least this would
be my logic if I tried to come up with helpers myself :-)

Also it's very annoying that each block is copy & pasted twice... so much
for the use of functions.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:5>

Ticket System

unread,
Jun 4, 2023, 9:51:42 AM6/4/23
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by musinsky):

Why not at least
{{{


< my $mloctime= strftime("%m-%d-%Y %H:%M:%S", localtime $mtime);

---


> my $mloctime= strftime("%m-%d-%Y %H:%M", localtime $mtime);
}}}

in {{{/usr/libexec/mc/fish/ls}}} file in {{{fish_list_perl ()}}} function
? this shows seconds.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:6>

Ticket System

unread,
Jun 4, 2023, 12:02:59 PM6/4/23
to opt...@gmail.com, mc-...@googlegroups.com
#4279: FISH download, file modification and access times truncated
--------------------------+---------------------------------------
Reporter: opty | Owner:

Type: defect | Status: new
Priority: major | Milestone: Future Releases
Component: mc-vfs | Version: 4.8.27
Resolution: | Keywords:

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------+---------------------------------------

Comment (by zaytsev):

andrew_b: I think we can add seconds to the Perl function, I have checked
the code and it seems to call `vfs_parse_filedate`, which tries to get
seconds if they are there, but if not, it works anyways. Meaning there
shouldn't be an issue if one function returns seconds and the others do
not... so if full portable solution is not possible at the moment, at
least the situation will get less shitty for most of the users.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4279#comment:7>

Reply all
Reply to author
Forward
0 new messages