mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-22 08:14:02 +01:00
Make uploading skipped history entries more efficient and use only one HTTP request
This commit is contained in:
parent
c16d260643
commit
9bfd4bf173
18
hishtory.go
18
hishtory.go
@ -263,16 +263,14 @@ func maybeUploadSkippedHistoryEntries(ctx *context.Context) error {
|
||||
return fmt.Errorf("failed to retrieve history entries that haven't been uploaded yet: %v", err)
|
||||
}
|
||||
hctx.GetLogger().Printf("Uploading %d history entries that previously failed to upload (query=%#v)\n", len(entries), query)
|
||||
for _, entry := range entries {
|
||||
jsonValue, err := lib.EncryptAndMarshal(config, []*data.HistoryEntry{entry})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = lib.ApiPost("/api/v1/submit?source_device_id="+config.DeviceId, "application/json", jsonValue)
|
||||
if err != nil {
|
||||
// Failed to upload the history entry, so we must still be offline. So just return nil and we'll try again later.
|
||||
return nil
|
||||
}
|
||||
jsonValue, err := lib.EncryptAndMarshal(config, entries)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = lib.ApiPost("/api/v1/submit?source_device_id="+config.DeviceId, "application/json", jsonValue)
|
||||
if err != nil {
|
||||
// Failed to upload the history entry, so we must still be offline. So just return nil and we'll try again later.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Mark down that we persisted it
|
||||
|
Loading…
Reference in New Issue
Block a user