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

Commit 3410b465 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MediaScanner: Disable bulk inserts



We are still finding bugs related to the bulk insert support,
so lets disable it for now.

Bug: 5026233

Change-Id: I436cd8fc5dbe9fcf220a623f1c070cf901c6d38c
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent aba367ee
Loading
Loading
Loading
Loading
+30 −14
Original line number Diff line number Diff line
@@ -312,6 +312,18 @@ public class MediaScanner

    private final String mExternalStoragePath;

    // WARNING: Bulk inserts sounded like a great idea and gave us a good performance improvement,
    // but unfortunately it also introduced a number of bugs.  Many of those bugs were fixed,
    // but (at least) two problems are still outstanding:
    //
    // 1) Bulk inserts broke the code that sets the default ringtones on first boot
    // 2) Bulk inserts broke file based playlists in the case where the playlist is processed
    //    at the same time the files in the playlist are inserted in the database
    //
    // These problems might be solvable by moving the logic to the media provider instead,
    // but for now we are disabling bulk inserts until we have solid fixes for these problems.
    private static final boolean ENABLE_BULK_INSERTS = false;

    // used when scanning the image database so we know whether we have to prune
    // old thumbnail files
    private int mOriginalCount;
@@ -1166,16 +1178,19 @@ public class MediaScanner
            prescan(null, true);
            long prescan = System.currentTimeMillis();

            if (ENABLE_BULK_INSERTS) {
                // create FileInserters for bulk inserts
                mAudioInserter = new FileInserter(mAudioUri, 500);
                mVideoInserter = new FileInserter(mVideoUri, 500);
                mImageInserter = new FileInserter(mImagesUri, 500);
                mFileInserter = new FileInserter(mFilesUri, 500);
            }

            for (int i = 0; i < directories.length; i++) {
                processDirectory(directories[i], mClient);
            }

            if (ENABLE_BULK_INSERTS) {
                // flush remaining inserts
                mAudioInserter.flush();
                mVideoInserter.flush();
@@ -1185,6 +1200,7 @@ public class MediaScanner
                mVideoInserter = null;
                mImageInserter = null;
                mFileInserter = null;
            }

            long scan = System.currentTimeMillis();
            postscan(directories);