Commit 732fab06 authored by Falk Alexander Seidl's avatar Falk Alexander Seidl

Reencode protected elementes after saving database

This is a workaround until the proposed fix for pykeepass is merged.
parent 10ecac8f
Pipeline #34606 passed with stage
in 8 minutes and 3 seconds
from gi.repository import Gio
from pykeepass.kdbx_parsing.kdbx import KDBX
from pykeepass import PyKeePass
import hashlib
......@@ -13,11 +15,13 @@ class DatabaseManager:
changes = False
save_running = False
scheduled_saves = 0
database_file_descriptor = NotImplemented
def __init__(self, database_path, password=None, keyfile=None, logging_manager=None):
self.logging_manager = logging_manager
self.db = PyKeePass(database_path, password, keyfile)
self.database_path = database_path
self.database_file_descriptor = Gio.File.new_for_path(database_path)
self.password = password
......@@ -341,9 +345,22 @@ class DatabaseManager:
def save_database(self):
if self.save_running is False and self.changes is True:
self.save_running = True
self.changes = False
self.logging_manager.log_debug("Saved database")
kdbx =, password=self.db.password, keyfile=self.db.keyfile)
output_stream = self.database_file_descriptor.replace(None, False, Gio.FileCreateFlags.REPLACE_DESTINATION | Gio.FileCreateFlags.PRIVATE, None)
self.logging_manager.log_debug("Saved database")
self.changes = False
except Exception:
self.logging_manager.log_error("Error occured while saving database")
# Workaround
# Fix created and proposed:
self.db.kdbx = KDBX.parse_file(self.db.filename, password=self.db.password, keyfile=self.db.keyfile)
self.save_running = False
# Set database password
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment