Skip to content

Commit 500c993

Browse files
committed
fix: Check for empty project root right before copying
The delay between checking the empty dir and copying a backup content might cause an issue. This fix moves the check right before the content is being copied which minimize the delay. Signed-off-by: Ales Raszka <araszka@redhat.com>
1 parent 1dbe84b commit 500c993

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

project-backup/workspace-recovery.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ restore() {
118118
--output /tmp
119119
)
120120

121-
# Check if $PROJECTS_ROOT is empty and exit if not
122-
if [[ -n "$(ls -A "$PROJECTS_ROOT")" ]]; then
123-
echo "PROJECTS_ROOT '$PROJECTS_ROOT' is not empty. Skipping restore action."
124-
exit 0
125-
fi
126-
127121
# Setup registry authentication
128122
setup_registry_auth "$BACKUP_IMAGE"
129123
oras_args+=("${ORAS_AUTH_ARGS[@]}")
@@ -138,6 +132,12 @@ restore() {
138132
mkdir /tmp/extracted-backup
139133
tar -xzvf /tmp/devworkspace-backup.tar.gz -C /tmp/extracted-backup
140134

135+
# Check if $PROJECTS_ROOT is empty and exit if not
136+
if [[ -n "$(ls -A "$PROJECTS_ROOT")" ]]; then
137+
echo "PROJECTS_ROOT '$PROJECTS_ROOT' is not empty. Skipping restore action."
138+
exit 0
139+
fi
140+
141141
cp -r /tmp/extracted-backup/* "$PROJECTS_ROOT"
142142

143143
rm -f /tmp/devworkspace-backup.tar.gz

0 commit comments

Comments
 (0)