// Failed to upload the history entry, so we must still be offline. So just return nil and we'll try again later.
returnnil
}
// Mark down that we persisted it
config.HaveMissedUploads=false
config.MissedUploadTimestamp=0
err=hctx.SetConfig(config)
iferr!=nil{
returnfmt.Errorf("failed to mark a history entry as uploaded: %v",err)
}
returnnil
}
funcsaveHistoryEntry(ctx*context.Context){
config:=hctx.GetConf(ctx)
if!config.IsEnabled{
hctx.GetLogger().Infof("Skipping saving a history entry because hishtory is disabled\n")
return
}
entry,err:=lib.BuildHistoryEntry(ctx,os.Args)
lib.CheckFatalError(err)
ifentry==nil{
hctx.GetLogger().Infof("Skipping saving a history entry because we did not build a history entry (was the command prefixed with a space and/or empty?)\n")
hctx.GetLogger().Infof("Failed to remotely persist hishtory entry because we failed to connect to the remote server! This is likely because the device is offline, but also could be because the remote server is having reliability issues. Original error: %v",err)
if!config.HaveMissedUploads{
config.HaveMissedUploads=true
config.MissedUploadTimestamp=time.Now().Unix()
lib.CheckFatalError(hctx.SetConfig(config))
}
}else{
lib.CheckFatalError(err)
}
}
}
// Check if there is a pending dump request and reply to it if so
dumpRequests,err:=lib.GetDumpRequests(config)
iferr!=nil{
iflib.IsOfflineError(err){
// It is fine to just ignore this, the next command will retry the API and eventually we will respond to any pending dump requests
dumpRequests=[]*shared.DumpRequest{}
hctx.GetLogger().Infof("Failed to check for dump requests because we failed to connect to the remote server!")