mirror of
https://github.com/mautrix/signal.git
synced 2025-03-14 14:15:36 +00:00
signalmeow/backup: sleep between requests if server is acting weird
This commit is contained in:
parent
5b0df8b893
commit
430b7317db
1 changed files with 10 additions and 1 deletions
|
@ -270,10 +270,19 @@ func (cli *Client) WaitForTransfer(ctx context.Context) (*TransferArchiveMetadat
|
|||
if remainingTime < 0 {
|
||||
return nil, fmt.Errorf("timed out")
|
||||
}
|
||||
resp, err := cli.tryRequestTransferArchive(ctx, min(remainingTime, 5*time.Minute))
|
||||
reqStart := time.Now()
|
||||
reqTimeout := min(remainingTime, 5*time.Minute)
|
||||
resp, err := cli.tryRequestTransferArchive(ctx, reqTimeout)
|
||||
if resp != nil || err != nil {
|
||||
return resp, err
|
||||
}
|
||||
reqDuration := time.Since(reqStart)
|
||||
if reqDuration < reqTimeout-10*time.Second {
|
||||
// There seems to be a bug or feature when the transfer fails that causes the server to
|
||||
// immediately return 204 until the user clicks "Continue" on their phone, so sleep for
|
||||
// a bit to avoid sending requests too often.
|
||||
time.Sleep(15 * time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue