KonradIT / mmt

Media Management Tool - make importing videos/photos from GoPro and other action cameras/drones a little bit more bearable.
http://mmt.camera
Apache License 2.0
109 stars 12 forks source link

make HTTP retry when the GoPro is overwhelmed #128

Closed klaernie closed 2 months ago

klaernie commented 9 months ago

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:

Camera:

Component:

Checklist before approval:

klaernie commented 2 months ago

Now the linter is happy - seems like I did not understand what it was failing on at the time I wrote this.