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

Commit fbc4939d authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MediaScanner: Fix handling of .nomedia files in directories



In particular, fix the code that prevents the database triggers from deleting
files when a .nomedia file is added to a directory

Change-Id: Ie913223f3b1bbf9122842a675b96d4baac3b1c6f
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 5eb40a85
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
@@ -389,6 +389,13 @@ public class MediaScanner
        return prop != null && prop.equals("true");
    }

    private final String mediaToExternalPath(String path) {
        if (mMediaStoragePath != null && path.startsWith(mMediaStoragePath)) {
            path = mExternalStoragePath + path.substring(mMediaStoragePath.length());
        }
        return path;
    }

    private class MyMediaScannerClient implements MediaScannerClient {

        private String mArtist;
@@ -463,12 +470,9 @@ public class MediaScanner
                }
            }

            String key = path;
            if (mMediaStoragePath != null && key.startsWith(mMediaStoragePath)) {
            // MediaProvider uses external variant of path for _data, so we need to match
            // against that path instead.
                key = mExternalStoragePath + key.substring(mMediaStoragePath.length());
            }
            String key = mediaToExternalPath(path);
            if (mCaseInsensitivePaths) {
                key = path.toLowerCase();
            }
@@ -881,6 +885,8 @@ public class MediaScanner
        }

        public void addNoMediaFolder(String path) {
            path = mediaToExternalPath(path);

            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.ImageColumns.DATA, "");
            String [] pathSpec = new String[] {path + '%'};
@@ -939,11 +945,9 @@ public class MediaScanner
        }

        if (filePath != null) {
            if (mMediaStoragePath != null && filePath.startsWith(mMediaStoragePath)) {
            // MediaProvider uses external variant of path for _data, so we need to query
            // using that path instead.
                filePath = mExternalStoragePath + filePath.substring(mMediaStoragePath.length());
            }
            filePath = mediaToExternalPath(filePath);

            // query for only one file
            where = Files.FileColumns.DATA + "=?";
@@ -1212,12 +1216,9 @@ public class MediaScanner
                // build file cache so we can look up tracks in the playlist
                prescan(null, true);

                String key = path;
                if (mMediaStoragePath != null && key.startsWith(mMediaStoragePath)) {
                // MediaProvider uses external variant of path for _data, so we need to match
                // against that path instead.
                    key = mExternalStoragePath + key.substring(mMediaStoragePath.length());
                }
                String key = mediaToExternalPath(path);
                if (mCaseInsensitivePaths) {
                    key = path.toLowerCase();
                }