mirror of
git://code.qt.io/qt/qt5.git
synced 2026-01-06 06:56:53 +08:00
Task-number: QTQAINFRA-7377 Pick-to: 6.9 6.8 6.5 Change-Id: Idf0dc607a4c6f7299412f6979f9ea6de5ea522cb Reviewed-by: Ville-Pekka Karhu <ville-pekka.karhu@qt.io>
42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright (C) 2017 The Qt Company Ltd.
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
|
|
|
# Allow retry in case mdutil fails with first tries
|
|
set +e
|
|
|
|
disableSpotlight() {
|
|
# Disable spotlight and and stop indexing
|
|
sudo mdutil -a -i off || return 1
|
|
sudo mdutil -a -i off / || return 1
|
|
# Disable spotlight indexing /Volumes
|
|
sudo mdutil -i off /Volumes || return 1
|
|
# Erase spotlight index
|
|
sudo mdutil -E / || return 1
|
|
}
|
|
|
|
fixUnknownIndexingState() {
|
|
echo "Fix unknown indexing state by enabling indexing back one by one"
|
|
sudo mdutil -i on / || return 1
|
|
sudo mdutil -i on /System/Volumes/Preboot || return 1
|
|
sudo mdutil -i on /System/Volumes/Data || return 1
|
|
}
|
|
|
|
# Disabling spotlight tends to be flaky, add some retry
|
|
for i in $(seq 1 5)
|
|
do
|
|
disableSpotlight
|
|
res=$?
|
|
if [[ $res -eq 0 ]]
|
|
then
|
|
echo "Spotlight disabled"
|
|
break
|
|
else
|
|
echo "Failed to disable spotlight, $i run fix and retry..."
|
|
fixUnknownIndexingState
|
|
sleep 2
|
|
fi
|
|
done
|
|
|
|
exit $res
|