Fix a race condition when restoring pane contents

If the pane contents files are deleted too
quickly then pane contents restoration fails.

Cleanup previous content JiT before a restore
rather than after a restore has happened to
avoid this
pull/328/head
Jamie Kirkpatrick 2020-02-13 22:01:10 +00:00
parent 905abba3c3
commit fc9602cfe3
2 changed files with 6 additions and 4 deletions

View File

@ -91,7 +91,12 @@ pane_contents_create_archive() {
pane_content_files_restore_from_archive() {
local archive_file="$(pane_contents_archive_file)"
if [ -f "$archive_file" ]; then
mkdir -p "$(pane_contents_dir "restore")"
rm "$(pane_contents_dir "restore")"/*
if [ -d "$(pane_contents_dir "restore")" ]; then
rm -rf "$(pane_contents_dir "restore")"/*
else
mkdir -p "$(pane_contents_dir "restore")"
fi
gzip -d < "$archive_file" |
tar xf - -C "$(resurrect_dir)/restore/"
fi

View File

@ -264,9 +264,6 @@ restore_all_panes() {
restore_pane "$line"
fi
done < $(last_resurrect_file)
if is_restoring_pane_contents; then
rm "$(pane_contents_dir "restore")"/*
fi
}
restore_pane_layout_for_each_window() {