Ticket #4279 (new defect)

Opened 3 years ago

Last modified 3 weeks ago

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:1 Changed 3 years ago 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?

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  
    55fish_list_lsq () 
    66{ 
    77FISH_DIR="$1" 
    8 ls -Qlan "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | ( 
    9 while read p l u g s m d y n; do 
     8ls -Qan --full-time "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | ( 
     9while read p l u g s d t z n; do 
    1010    echo "P$p $u.$g" 
    1111    echo "S$s" 
    12     echo "d$m $d $y" 
     12    echo "d${d#*-}-${d%%-*} ${t%.*}" 
    1313    echo ":$n" 
    1414    echo 
    1515done 
    1616) 
    1717 
    18 ls -Qlan "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | ( 
    19 while read p l u g a i m d y n; do 
     18ls -Qan --full-time "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | ( 
     19while read p l u g a i d t z n; do 
    2020    echo "P$p $u.$g" 
    2121    echo "E$a$i" 
    22     echo "d$m $d $y" 
     22    echo "d${d#*-}-${d%%-*} ${t%.*}" 
    2323    echo ":$n" 
    2424    echo 
    2525done 
     
    130130if (opendir (DIR, $dirname)) { 
    131131while((my $filename = readdir (DIR))){ 
    132132    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); 
    134134    my $strutils_shell_escape_regex = s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'\''"\ \\])/\\$1/g; 
    135135    my $e_filename = $filename; 
    136136    $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 13 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 13 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.

comment:8 Changed 3 weeks ago by opty

Related: FISH upload always updates remote file.

Workaround: Use SFTP or tar over ssh.

Note: See TracTickets for help on using tickets.