From 47cb8be0fea98c2f9d96b269278f2e011e810413 Mon Sep 17 00:00:00 2001 From: Vasu Nori Date: Wed, 12 Jan 2011 16:26:42 -0800 Subject: bug:3332449 downloadmanager deleting downloaded files sometimes removeSpuriousFiles() method in StorageManager.java is removing files because of it incorrectly thought a given file has NO entry in downloads db. more details: List files; String filename; files.remove(filename) remove should be new File(filename) most probably this fix also addresses bug:3324673 Change-Id: I22c58398fe874fa81939b575c782b6700a2cac4e --- src/com/android/providers/downloads/StorageManager.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/providers/downloads/StorageManager.java b/src/com/android/providers/downloads/StorageManager.java index e9638b8f..72658344 100644 --- a/src/com/android/providers/downloads/StorageManager.java +++ b/src/com/android/providers/downloads/StorageManager.java @@ -26,6 +26,7 @@ import android.net.Uri; import android.os.Environment; import android.os.StatFs; import android.provider.Downloads; +import android.text.TextUtils; import android.util.Log; import com.android.internal.R; @@ -373,14 +374,20 @@ class StorageManager { if (files.size() == 0) { return; } - Cursor cursor = mContext.getContentResolver().query( Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, new String[] { Downloads.Impl._DATA }, null, null, null); try { if (cursor != null) { while (cursor.moveToNext()) { - files.remove(cursor.getString(0)); + String filename = cursor.getString(0); + if (!TextUtils.isEmpty(filename)) { + if (Constants.LOGV) { + Log.i(Constants.TAG, "in removeSpuriousFiles, preserving file " + + filename); + } + files.remove(new File(filename)); + } } } } finally { -- cgit v1.2.3