mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-14 20:42:35 -04:00
Fixed tests and improved age logic
This commit is contained in:
parent
28f1cd398d
commit
c14725cf97
2 changed files with 31 additions and 17 deletions
|
@ -235,27 +235,25 @@ int Entry::getPasswordAge() const
|
|||
{
|
||||
QListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
Entry* compare = nullptr;
|
||||
Entry* curr = nullptr;
|
||||
const Entry* curr = nullptr;
|
||||
const Entry* previous = this;
|
||||
|
||||
while (i.hasPrevious()) {
|
||||
curr = i.previous();
|
||||
if (!compare) {
|
||||
compare = curr;
|
||||
continue;
|
||||
}
|
||||
if (*curr->attributes() != *compare->attributes()) {
|
||||
if (curr->password() != compare->password()) {
|
||||
// Found most recent password change; break out.
|
||||
break;
|
||||
}
|
||||
curr = previous;
|
||||
previous = i.previous();
|
||||
if (previous->password() != curr->password()) {
|
||||
// Found last change in history
|
||||
return curr->timeInfo().lastModificationTime().secsTo(Clock::currentDateTime());
|
||||
}
|
||||
|
||||
}
|
||||
if (!curr) {
|
||||
// If no change in history, password is from creation time
|
||||
return this->timeInfo().creationTime().secsTo(QDateTime::currentDateTime());
|
||||
if (previous!=this) {
|
||||
// If no change in history, password is from oldest history entry.
|
||||
// Not using creation time here because that changes when an entry is cloned
|
||||
return previous->timeInfo().lastModificationTime().secsTo(Clock::currentDateTime());
|
||||
}
|
||||
return curr->timeInfo().lastModificationTime().secsTo(QDateTime::currentDateTime());
|
||||
// If no history, creation time is when the password appeared
|
||||
return this->timeInfo().creationTime().secsTo(Clock::currentDateTime());
|
||||
}
|
||||
|
||||
bool Entry::excludeFromReports() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue