12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
appfsdir="$(cd "${appfsdir}" && pwd)"
if [ -z "${appfsdir}" ]; then
echo "Unable to find appfs directory." >&2
exit 1
fi
function sha1() {
local filename
filename="$1"
openssl sha1 "${filename}" | sed 's@.*= @@'
}
|
>
>
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
appfsdir="$(cd "${appfsdir}" && pwd)"
if [ -z "${appfsdir}" ]; then
echo "Unable to find appfs directory." >&2
exit 1
fi
mkdir -p "${appfsdir}/sha1"
function sha1() {
local filename
filename="$1"
openssl sha1 "${filename}" | sed 's@.*= @@'
}
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
;;
symlink)
stat_format='%Y'
extra_data="$(readlink "${filename}")"
;;
file)
stat_format='%Y,%s'
extra_data="$(sha1 "${filename}")"
;;
esac
stat_data="$(stat --format="${stat_format}" "${filename}")"
if [ -z "${extra_data}" ]; then
echo "${type},${stat_data},${extra_data},${filename}"
else
|
|
>
>
>
>
>
>
>
>
>
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
;;
symlink)
stat_format='%Y'
extra_data="$(readlink "${filename}")"
;;
file)
stat_format='%Y,%s'
filename_hash="$(sha1 "${filename}")"
extra_data="${filename_hash}"
filename_intree="${appfsdir}/sha1/${filename_hash}"
if [ ! -e "${filename_intree}" ]; then
cat "${filename}" > "${filename_intree}.tmp"
mv "${filename_intree}.tmp" "${filename_intree}"
fi
;;
esac
stat_data="$(stat --format="${stat_format}" "${filename}")"
if [ -z "${extra_data}" ]; then
echo "${type},${stat_data},${extra_data},${filename}"
else
|