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

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

MediaScanner: Fix problem with duplicate directory entries in the database



Bug: 5078643

Change-Id: I8804ff5bbd729f57be7ff0b17a4b134cafe78c18
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent ae65c179
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -872,10 +872,14 @@ public class MediaScanner
                    values.put(Files.FileColumns.FORMAT, format);
                }
                // new file, insert it
                if (inserter != null) {
                    result = inserter.insert(values);
                } else {
                // We insert directories immediately to ensure they are in the database
                // before the files they contain.
                // Otherwise we can get duplicate directory entries in the database
                // if one of the media FileInserters is flushed before the files table FileInserter
                if (inserter == null || entry.mFormat == MtpConstants.FORMAT_ASSOCIATION) {
                    result = mMediaProvider.insert(tableUri, values);
                } else {
                    result = inserter.insert(values);
                }

                if (result != null) {