MetadataService: refactor SaveHttpStream() with 'using' pattern
commit7dfb0b512f68c1fa19da0cb54561daa0d19bc172
authorAndrés G. Aragoneses <knocte@gmail.com>
Wed, 2 Apr 2014 12:24:29 +0000 (2 14:24 +0200)
committerAndrés G. Aragoneses <knocte@gmail.com>
Wed, 2 Apr 2014 12:24:29 +0000 (2 14:24 +0200)
tree9c660073b6b7cd6f8bb13c510d437e29344691de
parent0e5b8909166c9e6708593c53d4d1e82af3464bfc
MetadataService: refactor SaveHttpStream() with 'using' pattern

This method was extremely convoluted because it was checking
for nulls every time and calling Close() only in the proper
situations.

By employing the "using" pattern, we can achieve the same with
less checks and less explicit calls to Close(), as this pattern
checks for null before disposing, and the Dispose() methods of
both HttpWebResponse and Stream call Close() underneath.

The code becomes much more readable this way. (And this is also
safer against resource leaks because the calls to Dispose()
happen in a finally{} block.)
src/Core/Banshee.Services/Banshee.Metadata/MetadataServiceJob.cs