user dirs works final
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -29,13 +29,39 @@ class AppConfig:
|
||||
"font_size": 11,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _get_user_dirs() -> Dict[str, Path]:
|
||||
"""
|
||||
Parses ~/.config/user-dirs.dirs to get localized user folder paths.
|
||||
"""
|
||||
user_dirs_path = Path.home() / ".config/user-dirs.dirs"
|
||||
user_dirs = {}
|
||||
if user_dirs_path.exists():
|
||||
try:
|
||||
with open(user_dirs_path, 'r') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#') and '=' in line:
|
||||
key, value = line.split('=', 1)
|
||||
value = value.strip().strip('"')
|
||||
if value.startswith("$HOME"):
|
||||
value = value.replace(
|
||||
"$HOME", str(Path.home()))
|
||||
user_dirs[key] = Path(value)
|
||||
except Exception:
|
||||
# In case of any error, just return empty dict
|
||||
return {}
|
||||
return user_dirs
|
||||
|
||||
user_dirs = _get_user_dirs.__func__()
|
||||
|
||||
# --- Folder Paths ---
|
||||
FOLDER_PATHS: Dict[str, Path] = {
|
||||
"Computer": Path("/"),
|
||||
"Documents": Path.home() / "Dokumente",
|
||||
"Pictures": Path.home() / "Bilder",
|
||||
"Music": Path.home() / "Musik",
|
||||
"Videos": Path.home() / "Videos",
|
||||
"Documents": user_dirs.get("XDG_DOCUMENTS_DIR", Path.home() / "Documents"),
|
||||
"Pictures": user_dirs.get("XDG_PICTURES_DIR", Path.home() / "Pictures"),
|
||||
"Music": user_dirs.get("XDG_MUSIC_DIR", Path.home() / "Music"),
|
||||
"Videos": user_dirs.get("XDG_VIDEOS_DIR", Path.home() / "Videos"),
|
||||
}
|
||||
|
||||
STANDARD_EXCLUDE_CONTENT = """/dev/*
|
||||
|
@@ -4,7 +4,7 @@ import threading
|
||||
import re
|
||||
import signal
|
||||
import datetime
|
||||
from typing import Callable, Optional, List, Dict, Any
|
||||
from typing import Optional, List, Dict, Any
|
||||
from pathlib import Path
|
||||
from crontab import CronTab
|
||||
import tempfile
|
||||
@@ -133,7 +133,6 @@ class BackupManager:
|
||||
else:
|
||||
self.logger.log("No active backup process to cancel.")
|
||||
|
||||
|
||||
def start_backup(self, queue, source_path: str, dest_path: str, is_system: bool, is_dry_run: bool = False, exclude_files: Optional[List[Path]] = None, source_size: int = 0):
|
||||
"""Starts a generic backup process for a specific path, reporting to a queue."""
|
||||
thread = threading.Thread(target=self._run_backup_path, args=(
|
||||
|
Binary file not shown.
@@ -3,7 +3,6 @@ import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import os
|
||||
from queue import Queue, Empty
|
||||
import subprocess
|
||||
|
||||
from shared_libs.log_window import LogWindow
|
||||
from shared_libs.logger import app_logger
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,6 @@ from shared_libs.message import MessageDialog
|
||||
from shared_libs.custom_file_dialog import CustomFileDialog
|
||||
from app_config import AppConfig, Msg
|
||||
from shared_libs.logger import app_logger
|
||||
from shared_libs.animated_icon import AnimatedIcon
|
||||
from shared_libs.common_tools import message_box_animation
|
||||
|
||||
|
||||
@@ -84,7 +83,8 @@ class Actions:
|
||||
folder_path = AppConfig.FOLDER_PATHS.get(canonical_key)
|
||||
|
||||
if not folder_path or not folder_path.exists():
|
||||
print(f"Folder not found for {canonical_key} (Path: {folder_path})")
|
||||
print(
|
||||
f"Folder not found for {canonical_key} (Path: {folder_path})")
|
||||
self.app.start_pause_button.config(state="disabled")
|
||||
return
|
||||
|
||||
@@ -164,13 +164,16 @@ class Actions:
|
||||
# For system backup, use exclusions
|
||||
exclude_patterns = self.app.data_processing.load_exclude_patterns()
|
||||
target_method = self.app.data_processing.get_folder_size_threaded
|
||||
args = (folder_path, button_text, self.app.calculation_stop_event, exclude_patterns, self.app.mode)
|
||||
args = (folder_path, button_text, self.app.calculation_stop_event,
|
||||
exclude_patterns, self.app.mode)
|
||||
else:
|
||||
# For user folders, do not use any exclusions
|
||||
target_method = self.app.data_processing.get_user_folder_size_threaded
|
||||
args = (folder_path, button_text, self.app.calculation_stop_event, self.app.mode)
|
||||
args = (folder_path, button_text,
|
||||
self.app.calculation_stop_event, self.app.mode)
|
||||
|
||||
self.app.calculation_thread = threading.Thread(target=target_method, args=args)
|
||||
self.app.calculation_thread = threading.Thread(
|
||||
target=target_method, args=args)
|
||||
self.app.calculation_thread.daemon = True
|
||||
self.app.calculation_thread.start()
|
||||
|
||||
@@ -226,7 +229,7 @@ class Actions:
|
||||
size_str = f"{used / (1024**3):.2f} GB / {total / (1024**3):.2f} GB"
|
||||
|
||||
self.app.right_canvas_data.update({
|
||||
'folder': os.path.basename(path.rstrip('/')),
|
||||
'folder': os.path.basename(path.rstrip('/')),
|
||||
'path_display': path,
|
||||
'size': size_str
|
||||
})
|
||||
@@ -243,7 +246,7 @@ class Actions:
|
||||
|
||||
elif self.app.mode == "restore":
|
||||
self.app.right_canvas_data.update({
|
||||
'folder': os.path.basename(path.rstrip('/')),
|
||||
'folder': os.path.basename(path.rstrip('/')),
|
||||
'path_display': path,
|
||||
'size': ''
|
||||
})
|
||||
@@ -323,8 +326,8 @@ class Actions:
|
||||
for i, button in enumerate(self.app.nav_buttons):
|
||||
# Keep "Backup" and "Log" always enabled
|
||||
if (
|
||||
self.app.nav_buttons_defs[i][0] == Msg.STR["backup_menu"] or
|
||||
self.app.nav_buttons_defs[i][0] == Msg.STR["log"]):
|
||||
self.app.nav_buttons_defs[i][0] == Msg.STR["backup_menu"] or
|
||||
self.app.nav_buttons_defs[i][0] == Msg.STR["log"]):
|
||||
button.config(state="normal")
|
||||
else:
|
||||
button.config(state="normal" if enable else "disabled")
|
||||
@@ -490,4 +493,4 @@ class Actions:
|
||||
source_path=source,
|
||||
dest_path=dest,
|
||||
is_system=False,
|
||||
is_dry_run=is_dry_run)
|
||||
is_dry_run=is_dry_run)
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import os
|
||||
|
||||
from app_config import Msg
|
||||
from pyimage_ui.system_backup_content_frame import SystemBackupContentFrame
|
||||
@@ -17,8 +16,8 @@ class BackupContentFrame(ttk.Frame):
|
||||
# --- Header with buttons ---
|
||||
header_frame = ttk.Frame(self)
|
||||
header_frame.grid(row=0, column=0, sticky=tk.NSEW)
|
||||
self.grid_rowconfigure(1, weight=1) # Row for content frames
|
||||
self.grid_columnconfigure(0, weight=1) # Column for content frames
|
||||
self.grid_rowconfigure(1, weight=1) # Row for content frames
|
||||
self.grid_columnconfigure(0, weight=1) # Column for content frames
|
||||
|
||||
self.system_button = ttk.Button(
|
||||
header_frame, text=Msg.STR["system_backup_info"], command=self.show_system_backups)
|
||||
@@ -29,7 +28,8 @@ class BackupContentFrame(ttk.Frame):
|
||||
self.user_button.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
# --- Content Frames ---
|
||||
self.system_backups_frame = SystemBackupContentFrame(self, backup_manager)
|
||||
self.system_backups_frame = SystemBackupContentFrame(
|
||||
self, backup_manager)
|
||||
self.user_backups_frame = UserBackupContentFrame(self, backup_manager)
|
||||
|
||||
self.system_backups_frame.grid(row=1, column=0, sticky=tk.NSEW)
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import os
|
||||
import re
|
||||
|
||||
from app_config import Msg
|
||||
|
||||
@@ -29,7 +28,7 @@ class SystemBackupContentFrame(ttk.Frame):
|
||||
"size", text=Msg.STR["size"])
|
||||
self.content_tree.heading(
|
||||
"folder_name", text=Msg.STR["folder"])
|
||||
|
||||
|
||||
self.content_tree.column("date", width=120, anchor="w")
|
||||
self.content_tree.column("type", width=80, anchor="center")
|
||||
self.content_tree.column("size", width=100, anchor="e")
|
||||
@@ -60,7 +59,8 @@ class SystemBackupContentFrame(ttk.Frame):
|
||||
return
|
||||
|
||||
# Use the new method to get structured system backup data
|
||||
system_backups = self.backup_manager.list_system_backups(self.backup_path)
|
||||
system_backups = self.backup_manager.list_system_backups(
|
||||
self.backup_path)
|
||||
|
||||
for backup_info in system_backups:
|
||||
self.content_tree.insert("", "end", values=(
|
||||
|
Reference in New Issue
Block a user