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 () |
26 | 26 | |
27 | 27 | ugid="`id -nu` `id -ng`" |
28 | 28 | |
29 | | date_re='^\(....\)-\(..\)-\(..\) \(..:..:..\)' |
| 29 | date_re='^\(....\)-\(..\)-\(..\) \(..:..:..\)' # 19 chars. |
30 | 30 | date_mc='\2-\3-\1 \4' |
31 | | size_re='............' |
| 31 | |
| 32 | size_re='............' # 12 chars. |
| 33 | empty_size_re=' \{12\}' |
| 34 | zero_size=' 0' |
32 | 35 | |
33 | 36 | # archive entries can have no datetime info, 7z will use archive file datetime |
34 | 37 | date_archive=`stat -c %y "$1" 2>/dev/null | sed -n "s/${date_re}.*/${date_mc}/p" 2>/dev/null` |
… |
… |
mcu7zip_list () |
37 | 40 | |
38 | 41 | $P7ZIP l "$1" | sed -n " |
39 | 42 | |
| 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 | |
40 | 53 | # Handle directories. |
41 | 54 | s/$date_re D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_mc \5/p |
42 | 55 | s/^\s*D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_archive \1/p |