diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-06-16 17:06:37 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-06-16 17:06:39 -0700 |
commit | e3960ea97d5ddee80e5237796d577892e42a28cb (patch) | |
tree | be582199b04e2a622d6472c95d18e458896b8d06 /src/com/android/providers | |
parent | 810d83eac854f2da48f4ba7e7e6f68c39ce8f292 (diff) | |
download | android_packages_providers_DownloadProvider-e3960ea97d5ddee80e5237796d577892e42a28cb.tar.gz android_packages_providers_DownloadProvider-e3960ea97d5ddee80e5237796d577892e42a28cb.tar.bz2 android_packages_providers_DownloadProvider-e3960ea97d5ddee80e5237796d577892e42a28cb.zip |
Actually delete files when rows are deleted.
Otherwise they're orphaned until the next idle maintenance pass.
Bug: 21786983
Change-Id: I6eb2240d657366b65482bd3a0d5683e5d34a541a
Diffstat (limited to 'src/com/android/providers')
-rw-r--r-- | src/com/android/providers/downloads/DownloadProvider.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index 4b23024f..b19da709 100644 --- a/src/com/android/providers/downloads/DownloadProvider.java +++ b/src/com/android/providers/downloads/DownloadProvider.java @@ -1142,9 +1142,7 @@ public final class DownloadProvider extends ContentProvider { * Deletes a row in the database */ @Override - public int delete(final Uri uri, final String where, - final String[] whereArgs) { - + public int delete(final Uri uri, final String where, final String[] whereArgs) { if (shouldRestrictVisibility()) { Helpers.validateSelection(where, sAppReadableColumnsSet); } @@ -1161,12 +1159,21 @@ public final class DownloadProvider extends ContentProvider { deleteRequestHeaders(db, selection.getSelection(), selection.getParameters()); final Cursor cursor = db.query(DB_TABLE, new String[] { - Downloads.Impl._ID }, selection.getSelection(), selection.getParameters(), - null, null, null); + Downloads.Impl._ID, Downloads.Impl._DATA + }, selection.getSelection(), selection.getParameters(), null, null, null); try { while (cursor.moveToNext()) { final long id = cursor.getLong(0); DownloadStorageProvider.onDownloadProviderDelete(getContext(), id); + + final String path = cursor.getString(1); + if (!TextUtils.isEmpty(path)) { + final File file = new File(path); + if (Helpers.isFilenameValid(getContext(), file)) { + Log.v(Constants.TAG, "Deleting " + file + " via provider delete"); + file.delete(); + } + } } } finally { IoUtils.closeQuietly(cursor); |