summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2016-09-23 11:09:17 -0700
committerMarco Nelissen <marcone@google.com>2016-09-23 11:14:16 -0700
commit5835a6fccf5fec1a2829e1f398416d8d10d8916e (patch)
tree510574bfdc11e1af7d67653909cdfd2d412c77e6 /src/com
parent9f30b74dc758979afa9ccb1a36724dbddf79a840 (diff)
downloadMediaProvider-5835a6fccf5fec1a2829e1f398416d8d10d8916e.tar.gz
Fix check for existence of parent
When deleting, it's OK to delete entries that are parents of other entries, as long as all the children will be deleted as well. Also wrap the original where clause in parentheses to avoid problems when appending more conditions. Bug: 31685929 Change-Id: I488c6c732ed1bf252de6160b02900d131731c28f
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/providers/media/MediaProvider.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index d5b36da0b..9cb7d5ff7 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -4243,7 +4243,10 @@ public class MediaProvider extends ContentProvider {
// Do not allow deletion if the file/object is referenced as parent
// by some other entries. It could cause database corruption.
if (!TextUtils.isEmpty(sGetTableAndWhereParam.where)) {
- sGetTableAndWhereParam.where += " AND (" + ID_NOT_PARENT_CLAUSE + ")";
+ sGetTableAndWhereParam.where =
+ "(" + sGetTableAndWhereParam.where + ")" +
+ " AND (_id NOT IN (SELECT parent FROM files" +
+ " WHERE NOT (" + sGetTableAndWhereParam.where + ")))";
} else {
sGetTableAndWhereParam.where = ID_NOT_PARENT_CLAUSE;
}