mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-22 08:29:41 +01:00
completion of the path to backups
This commit is contained in:
@@ -7,7 +7,7 @@ from datetime import datetime
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from app.commons import run_idle
|
from app.commons import run_idle
|
||||||
from app.properties import Profile, get_default_settings
|
from app.properties import Profile
|
||||||
from app.ui.dialogs import show_dialog, DialogType
|
from app.ui.dialogs import show_dialog, DialogType
|
||||||
from app.ui.main_helper import append_text_to_tview
|
from app.ui.main_helper import append_text_to_tview
|
||||||
from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH
|
from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH
|
||||||
@@ -34,10 +34,9 @@ class BackupDialog:
|
|||||||
builder.add_from_file(UI_RESOURCES_PATH + "backup_dialog.glade")
|
builder.add_from_file(UI_RESOURCES_PATH + "backup_dialog.glade")
|
||||||
builder.connect_signals(handlers)
|
builder.connect_signals(handlers)
|
||||||
|
|
||||||
def_settings = get_default_settings().get(profile.value)
|
|
||||||
self._options = options.get(profile.value)
|
self._options = options.get(profile.value)
|
||||||
self._data_path = options.get("data_dir_path", def_settings["data_dir_path"])
|
self._data_path = self._options.get("data_dir_path", "")
|
||||||
self._backup_path = options.get("backup_dir_path", def_settings["backup_dir_path"])
|
self._backup_path = self._options.get("backup_dir_path", self._data_path + "backup/")
|
||||||
self._profile = profile
|
self._profile = profile
|
||||||
self._open_data_callback = callback
|
self._open_data_callback = callback
|
||||||
self._dialog_window = builder.get_object("dialog_window")
|
self._dialog_window = builder.get_object("dialog_window")
|
||||||
@@ -170,9 +169,9 @@ class BackupDialog:
|
|||||||
self._options["backup_tool_window_size"] = window.get_size()
|
self._options["backup_tool_window_size"] = window.get_size()
|
||||||
|
|
||||||
|
|
||||||
def backup_data(path):
|
def backup_data(path, backup_path):
|
||||||
""" Creating data backup from a folder at the specified path """
|
""" Creating data backup from a folder at the specified path """
|
||||||
backup_path = "{}backup/{}/".format(path, datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
|
backup_path = "{}{}/".format(backup_path, datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
|
||||||
os.makedirs(os.path.dirname(backup_path), exist_ok=True)
|
os.makedirs(os.path.dirname(backup_path), exist_ok=True)
|
||||||
# backup files in data dir(skipping dirs and satellites.xml)
|
# backup files in data dir(skipping dirs and satellites.xml)
|
||||||
for file in filter(lambda f: f != "satellites.xml" and os.path.isfile(os.path.join(path, f)), os.listdir(path)):
|
for file in filter(lambda f: f != "satellites.xml" and os.path.isfile(os.path.join(path, f)), os.listdir(path)):
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ class DownloadDialog:
|
|||||||
@run_idle
|
@run_idle
|
||||||
def on_receive(self, item):
|
def on_receive(self, item):
|
||||||
if self._profile_properties.get("backup_before_downloading", True):
|
if self._profile_properties.get("backup_before_downloading", True):
|
||||||
backup_data(self._profile_properties.get("data_dir_path", self._data_path_entry.get_text()))
|
data_path = self._profile_properties.get("data_dir_path", self._data_path_entry.get_text())
|
||||||
|
backup_path = self._profile_properties.get("backup_dir_path", data_path + "backup/")
|
||||||
|
backup_data(data_path, backup_path)
|
||||||
|
|
||||||
self.download(True, self.get_download_type())
|
self.download(True, self.get_download_type())
|
||||||
|
|
||||||
|
|||||||
@@ -881,8 +881,9 @@ class Application(Gtk.Application):
|
|||||||
profile = Profile(self._profile)
|
profile = Profile(self._profile)
|
||||||
options = self._options.get(self._profile)
|
options = self._options.get(self._profile)
|
||||||
path = options.get("data_dir_path")
|
path = options.get("data_dir_path")
|
||||||
|
backup_path = options.get("backup_dir_path", path + "backup/")
|
||||||
# Backup data or clearing data path
|
# Backup data or clearing data path
|
||||||
backup_data(path) if options.get("backup_before_save", True) else clear_data_path(path)
|
backup_data(path, backup_path) if options.get("backup_before_save", True) else clear_data_path(path)
|
||||||
|
|
||||||
bouquets = []
|
bouquets = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user