summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-05-10 14:01:05 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2010-05-10 14:01:05 -0700
commit055286d603745cb3281ddb04b0aa41a660624e65 (patch)
tree8e6a644439bd0d441ab22bccb4e8f2c61c27bd13
parente97073503ff1c7d3c4b5058ecc2602a62633428d (diff)
parent72f14a6f122f020e560e6572b2581c43b3ea90e3 (diff)
downloadandroid_packages_providers_DownloadProvider-055286d603745cb3281ddb04b0aa41a660624e65.zip
android_packages_providers_DownloadProvider-055286d603745cb3281ddb04b0aa41a660624e65.tar.gz
android_packages_providers_DownloadProvider-055286d603745cb3281ddb04b0aa41a660624e65.tar.bz2
merge from open-source master
Change-Id: If84d4054324db6d10fd0cdbd2169c039c6675726
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 3a61ace..d2bd322 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -695,8 +695,10 @@ http_request_loop:
FileUtils.setPermissions(filename, 0644, -1, -1);
// Sync to storage after completion
+ FileOutputStream downloadedFileStream = null;
try {
- new FileOutputStream(filename, true).getFD().sync();
+ downloadedFileStream = new FileOutputStream(filename, true);
+ downloadedFileStream.getFD().sync();
} catch (FileNotFoundException ex) {
Log.w(Constants.TAG, "file " + filename + " not found: " + ex);
} catch (SyncFailedException ex) {
@@ -705,6 +707,16 @@ http_request_loop:
Log.w(Constants.TAG, "IOException trying to sync " + filename + ": " + ex);
} catch (RuntimeException ex) {
Log.w(Constants.TAG, "exception while syncing file: ", ex);
+ } finally {
+ if(downloadedFileStream != null) {
+ try {
+ downloadedFileStream.close();
+ } catch (IOException ex) {
+ Log.w(Constants.TAG, "IOException while closing synced file: ", ex);
+ } catch (RuntimeException ex) {
+ Log.w(Constants.TAG, "exception while closing file: ", ex);
+ }
+ }
}
}
}