Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8a656b0 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

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
parent e7b2310a
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -462,7 +462,10 @@ public class MediaScanner
                key = path.toLowerCase();
            }
            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;
                if (isDirectory) {
                    tableUri = mFilesUri;
@@ -475,18 +478,17 @@ public class MediaScanner
                } else {
                    tableUri = mFilesUri;
                }
                entry = new FileCacheEntry(tableUri, 0, path, 0,
                if (wasModified) {
                    entry.mLastModified = lastModified;
                    entry.mTableUri = tableUri;
                } else {
                    entry = new FileCacheEntry(tableUri, 0, path, lastModified,
                            (isDirectory ? MtpConstants.FORMAT_ASSOCIATION : 0));
                    mFileCache.put(key, entry);
                }
            entry.mSeenInFileSystem = true;

            // add some slack to avoid a rounding error
            long delta = lastModified - entry.mLastModified;
            if (delta > 1 || delta < -1) {
                entry.mLastModified = lastModified;
                entry.mLastModifiedChanged = true;
            }
            entry.mSeenInFileSystem = true;

            if (mProcessPlaylists && MediaFile.isPlayListFileType(mFileType)) {
                mPlayLists.add(entry);