mmt icon indicating copy to clipboard operation
mmt copied to clipboard

make HTTP retry when the GoPro is overwhelmed

Open klaernie opened this issue 1 year ago • 0 comments

replace net.http with go-retryablehttp

My HERO12 did not like being asked for more than about 5-7 files simultaneously. Instead it dropped some of the /gp/gpMediaMetadata requests with a timeout. So after the files where the call to gpMediaMetadata was successful were downloaded, I got presented with a bunch of errors where it didn't work, and of cause those files were not downloaded.

Switching to a retrying approach means that we still hammer the GoPro for the first couple seconds, but allow the requests to proceed later.

Since go-retryablehttp allows it, I set it up to retry with a lot of jitter, so the camera should not get hit with multiple requests at the same time anymore. I also went for the approach that does not require touching all the points where the pkg/utils/client is used, but instead slipped retryablehttp underneath the Client that already was used in all other places.

Please note, as with my other PRs - I'm a beginner at working with golang, and fixed this mainly for me, since it cost me 3 days to import 35GB of footage due to having to retry again and again. So if anything of this jumps out as nonsensical, please tell me.

Type:

  • [X] Bug fix
  • [ ] New feature
  • [ ] Breaking change
  • [ ] Documentation

Camera:

  • [X] GoPro
  • [ ] Insta360
  • [ ] DJI
  • [ ] Android
  • [ ] This PR adds a new camera

Component:

  • [ ] Core logic
  • [X] Import
  • [ ] Merging
  • [ ] Firmware Update
  • [ ] Video Manipulation

Checklist before approval:

  • Linter pass
  • Build pass

klaernie avatar Feb 08 '24 21:02 klaernie