Ticket #2707: 2707-0002-extfs-u7z-handle-missing-size.patch

File 2707-0002-extfs-u7z-handle-missing-size.patch, 2.1 KB (added by mooffie, 2 years ago)
  • src/vfs/extfs/helpers/u7z

    From 3d74ac29e7456c77b32949131cf8ad6190d5c460 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Mon, 19 Dec 2016 02:06:18 +0200
    Subject: [PATCH 2/6] Ticket #2707: extfs: u7z: handle missing size.
    
    The uncompressed size may be missing in 7z's output (gods know why). We use the
    compressed size in this case.
    ---
     src/vfs/extfs/helpers/u7z | 17 +++++++++++++++--
     1 file changed, 15 insertions(+), 2 deletions(-)
    
    diff --git a/src/vfs/extfs/helpers/u7z b/src/vfs/extfs/helpers/u7z
    index 8270a20..52d123d 100755
    a b mcu7zip_list () 
    2626 
    2727        ugid="`id -nu` `id -ng`" 
    2828 
    29         date_re='^\(....\)-\(..\)-\(..\) \(..:..:..\)' 
     29        date_re='^\(....\)-\(..\)-\(..\) \(..:..:..\)' # 19 chars. 
    3030        date_mc='\2-\3-\1 \4' 
    31         size_re='............' 
     31 
     32        size_re='............' # 12 chars. 
     33        empty_size_re=' \{12\}' 
     34        zero_size='           0' 
    3235 
    3336        # archive entries can have no datetime info, 7z will use archive file datetime 
    3437        date_archive=`stat -c %y "$1" 2>/dev/null | sed -n "s/${date_re}.*/${date_mc}/p" 2>/dev/null` 
    mcu7zip_list () 
    3740 
    3841        $P7ZIP l "$1" | sed -n " 
    3942 
     43                  # If the uncompressed size is missing, we copy the compressed size onto it. 
     44                  # 
     45                  # But first, if the compressed size is missing too, set it to zero: 
     46                  s/^\(.\{19\} [D.]....\) $empty_size_re $empty_size_re/\1 $zero_size $zero_size/ 
     47                  # Next, do the copy: 
     48                  s/^\(.\{19\} [D.]....\) $empty_size_re \($size_re\)/\1 \2 \2/ 
     49                  # 
     50                  # (We use '.\{19\}' as the date may be missing. It may give false positives 
     51                  # but we don't mind: the printing commands that follow use strict patterns.). 
     52 
    4053                  # Handle directories. 
    4154                  s/$date_re D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_mc \5/p 
    4255                       s/^\s*D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_archive \1/p