From b05ab279ab9a34873aa22f07e676ca585c44f663 Mon Sep 17 00:00:00 2001
From: A Farzat
Date: Sat, 26 Apr 2025 11:38:46 +0300
Subject: [PATCH 1/2] Fix: update last file only after content is archived
This is to make sure the file referred to by last and the content
archive refer to the same time stamp in case the process is interrupted
while creating the archive.
---
scripts/save.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/save.sh b/scripts/save.sh
index 01edcdeb..b6660b2b 100755
--- a/scripts/save.sh
+++ b/scripts/save.sh
@@ -244,17 +244,17 @@ save_all() {
dump_windows >> "$resurrect_file_path"
dump_state >> "$resurrect_file_path"
execute_hook "post-save-layout" "$resurrect_file_path"
- if files_differ "$resurrect_file_path" "$last_resurrect_file"; then
- ln -fs "$(basename "$resurrect_file_path")" "$last_resurrect_file"
- else
- rm "$resurrect_file_path"
- fi
if capture_pane_contents_option_on; then
mkdir -p "$(pane_contents_dir "save")"
dump_pane_contents
pane_contents_create_archive
rm "$(pane_contents_dir "save")"/*
fi
+ if files_differ "$resurrect_file_path" "$last_resurrect_file"; then
+ ln -fs "$(basename "$resurrect_file_path")" "$last_resurrect_file"
+ else
+ rm "$resurrect_file_path"
+ fi
remove_old_backups
execute_hook "post-save-all"
}
From 6f281e5b0982f5ad2d85c78051c0048d3a397121 Mon Sep 17 00:00:00 2001
From: A Farzat
Date: Tue, 29 Apr 2025 15:54:05 +0300
Subject: [PATCH 2/2] Fix: keep a copy of last archive while compressing
Makes sure there is a working archive file copy in case the process is
killed while compressing.
---
scripts/helpers.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/scripts/helpers.sh b/scripts/helpers.sh
index 20d87dcd..660d4a00 100644
--- a/scripts/helpers.sh
+++ b/scripts/helpers.sh
@@ -81,8 +81,13 @@ is_session_grouped() {
# pane content file helpers
pane_contents_create_archive() {
+ local archive_file="$(pane_contents_archive_file)"
+ if [ -f "$archive_file" ]; then
+ mv "$archive_file" "$archive_file"-old
+ fi
tar cf - -C "$(resurrect_dir)/save/" ./pane_contents/ |
- gzip > "$(pane_contents_archive_file)"
+ gzip > "$archive_file"
+ rm "$archive_file"-old
}
pane_content_files_restore_from_archive() {