summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorusul <usultis@gmail.com>2010-03-28 16:26:05 +0100
committerSteve Kondik <shade@chemlab.org>2010-03-28 12:59:05 -0400
commit1a3eb08c9bbec308813db4349ecbac8b2b9d0cc5 (patch)
tree5aaa755b476e39b5eeb036e7ae36aaa0d578e922 /src
parente29a087959d7070d7552f113937905612f16d74f (diff)
downloadandroid_packages_providers_DownloadProvider-1a3eb08c9bbec308813db4349ecbac8b2b9d0cc5.tar.gz
android_packages_providers_DownloadProvider-1a3eb08c9bbec308813db4349ecbac8b2b9d0cc5.tar.bz2
android_packages_providers_DownloadProvider-1a3eb08c9bbec308813db4349ecbac8b2b9d0cc5.zip
code left opened files behind
verified with lsof DownloadProvider after downloading a file shows: ${proc} 338 10034 33w REG 179,0 167634 5 /sdcard/download/fw4-1.pdf Change-Id: I8e2412fe9a6348f5ece6f5ca3a9ebf99a4474bce
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index d899314b..d0a33bdf 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -694,8 +694,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) {
@@ -704,6 +706,14 @@ 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 e) {
+ Log.w(Constants.TAG, "IOException while closing synced file: ", e);
+ }
+ }
}
}
}