Skip to content

Commit f12bf57

Browse files
committed
feat: Quote backup paths to handle spaces and special chars
This fixes for the empty space paths like this: ```json "dirs_to_backup": [ "~/.zen/qknutvmw.Default Profile/", ] ```
1 parent 6f4cd29 commit f12bf57

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/commands/backup_command.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import itertools
88
import logging
99
import os
10+
import shlex
1011
import subprocess
1112
import sys
1213
import time
@@ -55,9 +56,13 @@ def _run_backup_process(self, total_size: int) -> None:
5556
# exclude_options += f" --exclude={self.config.backup_folder}"
5657

5758
dir_paths = [os.path.expanduser(path) for path in self.config.dirs_to_backup]
59+
60+
# Properly quote directory paths to handle spaces and special characters
61+
quoted_paths = [shlex.quote(path) for path in dir_paths]
62+
5863
# HACK: h option is used to follow symlinks
5964
cmd = (
60-
f"tar -chf - --one-file-system {exclude_options} {' '.join(dir_paths)} | "
65+
f"tar -chf - --one-file-system {exclude_options} {' '.join(quoted_paths)} | "
6166
f"xz --threads={os.cpu_count() - 1} > {self.config.backup_path}"
6267
)
6368
total_size_gb = total_size / 1024**3

0 commit comments

Comments
 (0)