mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 14:46:07 -04:00
Added history limits enforcement
This commit is contained in:
parent
860a2131b3
commit
8c87a87da6
6 changed files with 63 additions and 1 deletions
|
@ -337,6 +337,19 @@ void Entry::setExpiryTime(const QDateTime& dateTime)
|
|||
}
|
||||
}
|
||||
|
||||
int Entry::getHistSize() {
|
||||
int size = 0;
|
||||
|
||||
for(int i=0 ; i<m_history.size() ; i++) {
|
||||
size += m_history[i]->getSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int Entry::getSize() {
|
||||
return attributes()->attributesSize() + attachments()->attachmentsSize();
|
||||
}
|
||||
|
||||
QList<Entry*> Entry::historyItems()
|
||||
{
|
||||
return m_history;
|
||||
|
@ -353,9 +366,22 @@ void Entry::addHistoryItem(Entry* entry)
|
|||
Q_ASSERT(entry->uuid() == uuid());
|
||||
|
||||
m_history.append(entry);
|
||||
truncateHistory();
|
||||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
void Entry::truncateHistory() {
|
||||
const Database *db = database();
|
||||
if(db) {
|
||||
while(m_history.size() > db->metadata()->historyMaxItems()) {
|
||||
m_history.removeFirst();
|
||||
}
|
||||
while(getHistSize() > db->metadata()->historyMaxSize()) {
|
||||
m_history.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::beginUpdate()
|
||||
{
|
||||
Q_ASSERT(!m_tmpHistoryItem);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue