diff options
author | Mike Lockwood <lockwood@android.com> | 2011-08-14 14:39:12 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-14 14:39:12 -0700 |
commit | 52727fc38aaf6821bac6adf33235f154139638d0 (patch) | |
tree | 72662e82b6c81dccd633dd989f70f9a4c3c59cbd /media | |
parent | 5a586199cea242ea281744e8e35969ac342cbe80 (diff) | |
parent | f2e2b523dd333207107b50bc174f152e954dc371 (diff) | |
download | frameworks_base-52727fc38aaf6821bac6adf33235f154139638d0.zip frameworks_base-52727fc38aaf6821bac6adf33235f154139638d0.tar.gz frameworks_base-52727fc38aaf6821bac6adf33235f154139638d0.tar.bz2 |
Merge "MediaScanner: Clear file path before deleting records to avoid accidental file deletions"
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaScanner.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 2d1761f..65818a1 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -1122,19 +1122,23 @@ public class MediaScanner } if (fileMissing) { + // Clear the file path to prevent the _DELETE_FILE database hook + // in the media provider from deleting the file. + // If the file is truly gone the delete is unnecessary, and we want to avoid + // accidentally deleting files that are really there. + ContentValues values = new ContentValues(); + values.put(Files.FileColumns.DATA, ""); + values.put(Files.FileColumns.DATE_MODIFIED, 0); + mMediaProvider.update(ContentUris.withAppendedId(mFilesUri, entry.mRowId), + values, null, null); + // do not delete missing playlists, since they may have been modified by the user. // the user can delete them in the media player instead. // instead, clear the path and lastModified fields in the row MediaFile.MediaFileType mediaFileType = MediaFile.getFileType(path); int fileType = (mediaFileType == null ? 0 : mediaFileType.fileType); - if (MediaFile.isPlayListFileType(fileType)) { - ContentValues values = new ContentValues(); - values.put(MediaStore.Audio.Playlists.DATA, ""); - values.put(MediaStore.Audio.Playlists.DATE_MODIFIED, 0); - mMediaProvider.update(ContentUris.withAppendedId(mPlaylistsUri, entry.mRowId), - values, null, null); - } else { + if (!MediaFile.isPlayListFileType(fileType)) { mMediaProvider.delete(ContentUris.withAppendedId(mFilesUri, entry.mRowId), null, null); iterator.remove(); |