summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/providers/downloads/DownloadService.java34
-rw-r--r--src/com/android/providers/downloads/Helpers.java16
2 files changed, 24 insertions, 26 deletions
diff --git a/src/com/android/providers/downloads/DownloadService.java b/src/com/android/providers/downloads/DownloadService.java
index d5dff564..9bcfe7f5 100644
--- a/src/com/android/providers/downloads/DownloadService.java
+++ b/src/com/android/providers/downloads/DownloadService.java
@@ -370,21 +370,20 @@ public class DownloadService extends Service {
if (!scanFile(info, false, true)) {
throw new IllegalStateException("scanFile failed!");
}
- } else {
- // this file should NOT be scanned. delete the file.
- Helpers.deleteFile(getContentResolver(), info.mId, info.mFileName,
- info.mMimeType);
+ continue;
}
} else {
// yes it has mediaProviderUri column already filled in.
- // delete it from MediaProvider database and then from downloads table
- // in DownProvider database (the order of deletion is important).
+ // delete it from MediaProvider database.
getContentResolver().delete(Uri.parse(info.mMediaProviderUri), null,
null);
- getContentResolver().delete(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI,
- Downloads.Impl._ID + " = ? ",
- new String[]{String.valueOf(info.mId)});
}
+ // delete the file
+ deleteFileIfExists(info.mFileName);
+ // delete from the downloads db
+ getContentResolver().delete(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI,
+ Downloads.Impl._ID + " = ? ",
+ new String[]{String.valueOf(info.mId)});
}
}
}
@@ -601,7 +600,11 @@ public class DownloadService extends Service {
getContentResolver().delete(uri, null, null);
}
// delete the file and delete its row from the downloads db
- Helpers.deleteFile(resolver, id, path, mimeType);
+ deleteFileIfExists(path);
+ getContentResolver().delete(
+ Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI,
+ Downloads.Impl._ID + " = ? ",
+ new String[]{String.valueOf(id)});
}
}
});
@@ -612,4 +615,15 @@ public class DownloadService extends Service {
}
}
}
+
+ private void deleteFileIfExists(String path) {
+ try {
+ if (!TextUtils.isEmpty(path)) {
+ File file = new File(path);
+ file.delete();
+ }
+ } catch (Exception e) {
+ Log.w(Constants.TAG, "file: '" + path + "' couldn't be deleted", e);
+ }
+ }
}
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index 2d571ead..59cc97cf 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -16,7 +16,6 @@
package com.android.providers.downloads;
-import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
@@ -852,19 +851,4 @@ public class Helpers {
}
return sb.toString();
}
-
- /*
- * Delete the given file from device
- * and delete its row from the downloads database.
- */
- /* package */ static void deleteFile(ContentResolver resolver, long id, String path, String mimeType) {
- try {
- File file = new File(path);
- file.delete();
- } catch (Exception e) {
- Log.w(Constants.TAG, "file: '" + path + "' couldn't be deleted", e);
- }
- resolver.delete(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, Downloads.Impl._ID + " = ? ",
- new String[]{String.valueOf(id)});
- }
}