Changeset 610 in code


Ignore:
Timestamp:
Oct 7, 2021, 9:57:42 AM (4 years ago)
Author:
alex
Message:

chathistory: Fix truncated backlog due to timezones

Because msgstore_fs writes logs in localtime, the CHATHISTORY timestamps
(UTC) must be converted to localtime prior to filtering ranges ensure
the right range is sent back to the client.

Prior to this patch, the iteration back from the BEFORE time failed to
load the hours between midnight UTC and midnight localtime in each day's
logged messages. This is because the final time to be considered in a
day's log file (the "start" time) reuses the previous start time's
locale:

start = time.Date(year, month, day, 0, 0, 0, 0, start.Location()).Add(-1)

By converting the original start and end from the CHATHISTORY commands
to localtime in Load*Time and ListTargets, we ensure we read through
midnight each day.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/msgstore_fs.go

    r608 r610  
    384384
    385385func (ms *fsMessageStore) LoadBeforeTime(network *network, entity string, start time.Time, end time.Time, limit int) ([]*irc.Message, error) {
     386        start = start.In(time.Local)
     387        end = end.In(time.Local)
    386388        history := make([]*irc.Message, limit)
    387389        remaining := limit
     
    407409
    408410func (ms *fsMessageStore) LoadAfterTime(network *network, entity string, start time.Time, end time.Time, limit int) ([]*irc.Message, error) {
     411        start = start.In(time.Local)
     412        end = end.In(time.Local)
    409413        var history []*irc.Message
    410414        remaining := limit
     
    473477
    474478func (ms *fsMessageStore) ListTargets(network *network, start, end time.Time, limit int) ([]chatHistoryTarget, error) {
     479        start = start.In(time.Local)
     480        end = end.In(time.Local)
    475481        rootPath := filepath.Join(ms.root, escapeFilename(network.GetName()))
    476482        root, err := os.Open(rootPath)
Note: See TracChangeset for help on using the changeset viewer.