Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion synctestdata.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Script that synchronizes the local test data

Function Retry
{
param(
[scriptblock]$Command
)

$Attempt = 1
$Sleep = 4

while ($true)
{
try
{
& $Command
return
}
catch
{
if ($Attempt -ge 5)
{
throw
}
Start-Sleep -Seconds $Sleep
$Attempt++
$Sleep = $Sleep * 2
}
}
}

$TestsInputDirectory = "tests\input"
$TestSet = "public"
$TestFiles = "outlook.pst"
Expand All @@ -24,5 +53,5 @@ ForEach ($TestFile in ${TestFiles} -split " ")
$Url = "https://raw.githubusercontent.com/libyal/testdata/refs/heads/main/pst/${UrlTestFile}"

$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri ${Url} -OutFile "${TestsInputDirectory}\${TestSet}\${TestFile}"
Retry { Invoke-WebRequest -Uri ${Url} -OutFile "${TestsInputDirectory}\${TestSet}\${TestFile}" }
}
27 changes: 26 additions & 1 deletion synctestdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ TESTS_INPUT_DIRECTORY="tests/input"
TEST_SET="public"
TEST_FILES="outlook.pst"

# Retries a command
retry()
{
ATTEMPT=1
SLEEP=4

while test ${ATTEMPT} -le 5
do
if "$@"
then
return 0
fi
if test ${ATTEMPT} -eq 5
then
echo "Unable to run: $*"

exit 1
fi
sleep ${SLEEP}

ATTEMPT=`expr ${ATTEMPT} + 1`
SLEEP=`expr ${SLEEP} \* 2`
done
}

mkdir -p "${TESTS_INPUT_DIRECTORY}/.pffexport_recovered"
echo "-mrecovered" > "${TESTS_INPUT_DIRECTORY}/.pffexport_recovered/options"

Expand All @@ -14,5 +39,5 @@ for TEST_FILE in ${TEST_FILES}
do
URL="https://raw.githubusercontent.com/libyal/testdata/refs/heads/main/pst/${TEST_FILE}"

curl -L -o "${TESTS_INPUT_DIRECTORY}/${TEST_SET}/${TEST_FILE}" ${URL}
retry curl -L -o "${TESTS_INPUT_DIRECTORY}/${TEST_SET}/${TEST_FILE}" ${URL}
done