mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
When storing old versions of files for use in generating new files via
patching and for rolling back updates, don't copy a file if it has already been stored. This provides a significant speedup to the "Preparing to download files" stage of "freebsd-update fetch" if many updates have already been applied or if a file being updated is linked many times (such as /rescue/*). Reported by: Paul Dekkers MFC after: 1 week Approved by: re (bmah)
This commit is contained in:
parent
0201e3e97b
commit
210b8123c3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171784
@ -1365,12 +1365,27 @@ fetch_files_prepare () {
|
||||
# Copy all files into /files/. We only need the unmodified files
|
||||
# for use in patching; but we'll want all of them if the user asks
|
||||
# to rollback the updates later.
|
||||
cut -f 1 -d '|' < $2.hashes |
|
||||
while read F; do
|
||||
while read LINE; do
|
||||
F=`echo "${LINE}" | cut -f 1 -d '|'`
|
||||
HASH=`echo "${LINE}" | cut -f 2 -d '|'`
|
||||
|
||||
# Skip files we already have.
|
||||
if [ -f files/${HASH}.gz ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Make sure the file hasn't changed.
|
||||
cp "${BASEDIR}/${F}" tmpfile
|
||||
gzip -c < tmpfile > files/`sha256 -q tmpfile`.gz
|
||||
if [ `sha256 -q tmpfile` != ${HASH} ]; then
|
||||
echo
|
||||
echo "File changed while FreeBSD Update running: ${F}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Place the file into storage.
|
||||
gzip -c < tmpfile > files/${HASH}.gz
|
||||
rm tmpfile
|
||||
done
|
||||
done < $2.hashes
|
||||
|
||||
# Produce a list of patches to download
|
||||
sort -k 1,1 -t '|' $3.hashes |
|
||||
@ -1665,7 +1680,7 @@ fetch_run () {
|
||||
# Prepare to fetch files: Generate a list of the files we need,
|
||||
# copy the unmodified files we have into /files/, and generate
|
||||
# a list of patches to download.
|
||||
fetch_files_prepare INDEX-OLD INDEX-PRESENT INDEX-NEW
|
||||
fetch_files_prepare INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1
|
||||
|
||||
# Fetch files.
|
||||
fetch_files || return 1
|
||||
|
Loading…
Reference in New Issue
Block a user