mirror of https://github.com/gmbrax/Pilgrim.git
Compare commits
8 Commits
9bbccdc676
...
3c71b0abe6
| Author | SHA1 | Date |
|---|---|---|
|
|
3c71b0abe6 | |
|
|
c3397ab982 | |
|
|
bb9457978c | |
|
|
c09425cd48 | |
|
|
7c950b93ab | |
|
|
17371088da | |
|
|
209099cc5e | |
|
|
890fc470bb |
|
|
@ -14,9 +14,12 @@ class BackupService:
|
||||||
db_path = DirectoryManager.get_database_path()
|
db_path = DirectoryManager.get_database_path()
|
||||||
if not db_path.exists():
|
if not db_path.exists():
|
||||||
raise FileNotFoundError("No Database Found")
|
raise FileNotFoundError("No Database Found")
|
||||||
conn = self.session.connection().connection
|
|
||||||
dump = "\n".join(line for line in conn.iterdump())
|
with self.session.connection() as conn:
|
||||||
filename = str(DirectoryManager.get_config_directory()) + "/backup.zip"
|
raw_conn = conn.connection
|
||||||
|
dump = "\n".join(line for line in raw_conn.iterdump())
|
||||||
|
|
||||||
|
filename = DirectoryManager.get_config_directory() / "backup.zip"
|
||||||
diaries_root_path = DirectoryManager.get_diaries_root()
|
diaries_root_path = DirectoryManager.get_diaries_root()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -27,7 +30,7 @@ class BackupService:
|
||||||
if file_path.is_file():
|
if file_path.is_file():
|
||||||
arcname = file_path.relative_to(diaries_root_path.parent)
|
arcname = file_path.relative_to(diaries_root_path.parent)
|
||||||
zipf.write(file_path, arcname=arcname)
|
zipf.write(file_path, arcname=arcname)
|
||||||
return True, None
|
return True, filename
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, str(e)
|
return False, str(e)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,12 @@ class DiaryListScreen(Screen):
|
||||||
session = self.app.service_manager.get_session()
|
session = self.app.service_manager.get_session()
|
||||||
if session:
|
if session:
|
||||||
backup_service = BackupService(session)
|
backup_service = BackupService(session)
|
||||||
result = backup_service.create_backup()
|
result_operation, result_data = backup_service.create_backup()
|
||||||
|
if result_operation:
|
||||||
|
self.notify(f"Backup result: {result_data}")
|
||||||
|
else:
|
||||||
|
self.notify(f"Error performing backup: {result_data}")
|
||||||
else:
|
else:
|
||||||
self.notify("You must be logged in to perform this action")
|
self.notify("Error: Session not found",severity="error")
|
||||||
self.notify(f"Backup result: {result}")
|
self.app.exit()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue