Fix scanning of modified files.

When a media file, particularly a music file, is updated, the media
scanner should use the correct Uri to update it, and not the generic
files Uri. Otherwise, things like artist and album name will not
be properly updated.

Change-Id: I576629c51282bfbeb61c23f1e43b072700084a6c
This commit is contained in:
Marco Nelissen
2011-01-12 14:30:30 -08:00
parent e7b2310a85
commit a8a656b0c5

View File

@@ -462,7 +462,10 @@ public class MediaScanner
key = path.toLowerCase(); key = path.toLowerCase();
} }
FileCacheEntry entry = mFileCache.get(key); FileCacheEntry entry = mFileCache.get(key);
if (entry == null) { // add some slack to avoid a rounding error
long delta = (entry != null) ? (lastModified - entry.mLastModified) : 0;
boolean wasModified = delta > 1 || delta < -1;
if (entry == null || wasModified) {
Uri tableUri; Uri tableUri;
if (isDirectory) { if (isDirectory) {
tableUri = mFilesUri; tableUri = mFilesUri;
@@ -475,18 +478,17 @@ public class MediaScanner
} else { } else {
tableUri = mFilesUri; tableUri = mFilesUri;
} }
entry = new FileCacheEntry(tableUri, 0, path, 0, if (wasModified) {
(isDirectory ? MtpConstants.FORMAT_ASSOCIATION : 0)); entry.mLastModified = lastModified;
mFileCache.put(key, entry); entry.mTableUri = tableUri;
} } else {
entry.mSeenInFileSystem = true; entry = new FileCacheEntry(tableUri, 0, path, lastModified,
(isDirectory ? MtpConstants.FORMAT_ASSOCIATION : 0));
// add some slack to avoid a rounding error mFileCache.put(key, entry);
long delta = lastModified - entry.mLastModified; }
if (delta > 1 || delta < -1) {
entry.mLastModified = lastModified;
entry.mLastModifiedChanged = true; entry.mLastModifiedChanged = true;
} }
entry.mSeenInFileSystem = true;
if (mProcessPlaylists && MediaFile.isPlayListFileType(mFileType)) { if (mProcessPlaylists && MediaFile.isPlayListFileType(mFileType)) {
mPlayLists.add(entry); mPlayLists.add(entry);