unity-builder/dist/remote-builder/handleCaching.sh

48 lines
958 B
Bash
Raw Normal View History

#!/bin/sh
2021-07-12 22:46:21 +00:00
cacheDir=$1
branchName=$2
libDir=$3
purgeRemoteBuilderCache=$4
2021-07-27 20:45:49 +00:00
# handle library cache
if [ ! -d $cacheFolderFull ]; then
mkdir $cacheFolderFull
echo "creating new cache folder"
fi
if [ ! -d $cacheFolderFull/$branchName ]; then
mkdir $cacheFolderFull/$branchName
echo "creating new cache branch folder for: ${branchName}"
fi
echo "Library cache for branch: $branchName"
ls $cacheFolderFull/$branchName
echo ''
if [ -d $libraryFolderFull ]; then
rm -r $libraryFolderFull
echo "Git must ignore the Library folder"
fi
echo "Checking cache"
2021-07-12 22:36:40 +00:00
# Restore library cache
2021-07-12 22:46:21 +00:00
latest=$(ls -t $cacheDir | head -1)
if [ ! -z "$latest" ]; then
echo "Library cache exists from build $latest from $branchName"
echo 'Creating empty Library folder for cache'
mkdir $libDir
unzip -q $latest -d $libDir
else
echo 'Cache does not exist'
fi
2021-07-12 22:36:40 +00:00
# Restore LFS cache
# purge cache
if [ "$purgeRemoteBuilderCache" == "true" ]; then
rm -r $libDir
fi