Ticket #4279 (new defect)
FISH download, file modification and access times truncated
Reported by: | opty | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | Future Releases |
Component: | mc-vfs | Version: | 4.8.27 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
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).
Change History
comment:2 Changed 3 years ago 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.
comment:3 Changed 3 years ago by opty
So far (seconds):
-
usr/libexec/mc/fish/ls
old new 5 5 fish_list_lsq () 6 6 { 7 7 FISH_DIR="$1" 8 ls -Q lan"${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | (9 while read p l u g s m d yn; do8 ls -Qan --full-time "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | ( 9 while read p l u g s d t z n; do 10 10 echo "P$p $u.$g" 11 11 echo "S$s" 12 echo "d$ m $d $y"12 echo "d${d#*-}-${d%%-*} ${t%.*}" 13 13 echo ":$n" 14 14 echo 15 15 done 16 16 ) 17 17 18 ls -Q lan"${FISH_DIR}" 2>/dev/null | grep '^[cb]' | (19 while read p l u g a i m d yn; do18 ls -Qan --full-time "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | ( 19 while read p l u g a i d t z n; do 20 20 echo "P$p $u.$g" 21 21 echo "E$a$i" 22 echo "d$ m $d $y"22 echo "d${d#*-}-${d%%-*} ${t%.*}" 23 23 echo ":$n" 24 24 echo 25 25 done … … 130 130 if (opendir (DIR, $dirname)) { 131 131 while((my $filename = readdir (DIR))){ 132 132 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = lstat("$dirname/$filename"); 133 my $mloctime= strftime("%m-%d-%Y %H:%M ", localtime $mtime);133 my $mloctime= strftime("%m-%d-%Y %H:%M:%S", localtime $mtime); 134 134 my $strutils_shell_escape_regex = s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'\''"\ \\])/\\$1/g; 135 135 my $e_filename = $filename; 136 136 $e_filename =~ $strutils_shell_escape_regex;
comment:4 Changed 3 years ago by andrew_b
ls --full-time is not portable. GNU ls has this option, but BSD hasn't.
comment:5 Changed 3 years ago 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.
comment:6 Changed 19 months ago 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.
comment:7 Changed 19 months ago 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.
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?