Profiles: Fixes for firstHeardAbout and/or lastHeardAbout being zero

This commit is contained in:
zzz
2024-05-02 16:57:50 -04:00
parent 0b31e9504c
commit 0efb0017e8
4 changed files with 11 additions and 3 deletions

View File

@ -269,7 +269,7 @@ public class PeerProfile {
* Also sets FirstHeardAbout if earlier
*/
public synchronized void setLastHeardAbout(long when) {
if (_lastHeardAbout <= 0 || when > _lastHeardAbout)
if (when > _lastHeardAbout)
_lastHeardAbout = when;
// this is called by netdb PersistentDataStore, so fixup first heard
if (when < _firstHeardAbout)

View File

@ -364,6 +364,7 @@ public class ProfileManagerImpl implements ProfileManager {
PeerProfile prof = _context.profileOrganizer().getProfile(peer);
if (prof == null) {
prof = new PeerProfile(_context, peer);
prof.setLastHeardAbout(prof.getFirstHeardAbout());
_context.profileOrganizer().addProfile(prof);
}
return prof;

View File

@ -218,6 +218,7 @@ public class ProfileOrganizer {
if (rv != null)
return rv;
rv = new PeerProfile(_context, peer);
rv.setLastHeardAbout(rv.getFirstHeardAbout());
rv.coalesceStats();
if (!tryWriteLock())
return null;

View File

@ -325,8 +325,14 @@ class ProfilePersistenceHelper {
profile.setIntegrationBonus((int) getLong(props, "integrationBonus"));
profile.setSpeedBonus((int) getLong(props, "speedBonus"));
profile.setLastHeardAbout(getLong(props, "lastHeardAbout"));
profile.setFirstHeardAbout(getLong(props, "firstHeardAbout"));
long fh = getLong(props, "firstHeardAbout");
if (fh <= 0)
fh = file.lastModified();
profile.setFirstHeardAbout(fh);
long lh = getLong(props, "lastHeardAbout");
if (lh <= 0)
lh = fh;
profile.setLastHeardAbout(lh);
profile.setLastSendSuccessful(getLong(props, "lastSentToSuccessfully"));
profile.setLastSendFailed(getLong(props, "lastFailedSend"));
profile.setLastHeardFrom(getLong(props, "lastHeardFrom"));