Check DOING_AUTOSAVE before flushing transients

So that we don’t flush transients more often than necessary.

Fixes #646
Merge pull request #648 from nickdaugherty/check-autosaves

Check DOING_AUTOSAVE before flushing transients.

Fixes #646.