The Picasa importer was deadlocking inside the golang.org/x/oauth2
package because the Picasa code was mutating its parent's context and
accidentally creating a cycle of *oauth2.reuseTokenSource values
(double-acquisition of the reuseTokenSource's sync.Mutex was the
deadlock)
The Picasa code really just wanted to create a subcontext from the
base context, where the subcontext did the oauth2 wrapping, but then
picasa was storing that subcontext in the
camlistore.org/pkg/importer-provided mutable "RunContext" structure's
public, embedded "context.Context" field. Unfortunately, the picasa
importer code had already used that *RunContext (pre-mutation) as the
context.Context for the base HTTP client.
This change changes the camlistore.org/pkg/importer.RunContext to not
have a public embedded Context field. Instead, it only has a read-only
accessor to get at the base context, similar to Go 1.7's
net/http.Request.Context() field. This will prevent this class of
error in the future.
Fixes#698
Change-Id: I9114b64aa1bfd7ea83b36ea1ab18ed88b4a44f7e
The import path was added to the go file that included the package
documentation if one existed. Otherwise, I used what seemed to be the
primary file for the package.
Fixes#689
Change-Id: If51be0e86529fd6f179e80af6781e639f8550fd2
side-effect: fix an unchecked type assertion, and use a conventional
key for the HTTP client associated with the context (instead of our own
string).
Change-Id: I2701de3f41f1f1c56fe3b76bbf590c0e5b39bc72
As Adrian Tritschler reported, Flickr returns Lat/Long
with inconsistent quoting: 0 / "-32.2".
Also ints ("total", for example) can come in quoted ("6236") and
unquoted (6236) form, too.
This commit utilizes an int and a float32 with specialized Unmarshaler.
Change-Id: Ic559059272ba457860bf56a8671d5abd430eb404
If an importer is efficient at running regularly, it returns true.
If it's not true, the UI won't allow turning on automatic runs.
Flickr doesn't set it (yet).
Works but only lightly tested.
Could use lots of refactoring with code common with twitter.
Needs a test too.
Change-Id: I07f72d29acbc0226aeeedba0afe0bf7eeeac5ad3
httputil.CloseBody closes a http.Response.Body nicely, such that it's
more likely to be re-used.
httputil.DecodeJSON parses JSON from a Response.Body and closes the
body. It also keeps a temporary copy of the input, for error messages.
Then use them everywhere, to improve HTTP TCP connection re-use.
And misc other clean-ups.
Change-Id: I5dc44be0165b13659459ed29ce5ab44c17d9739f
Remove the mutex from auth.go because I believe the
mutex in importer.go should guaranteeing only one
flickr importer is running at a time.
Change-Id: Ice971c6c041cf21fdb2bc93cb15f861dd1c8c1d7