From 8b1c74f96f93195326907db1bb07a3787a1c1b45 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Mon, 2 May 2011 17:01:47 -0400 Subject: [PATCH] DO NOT MERGE MediaScanner: Fix bug in "no media" handling logic Don't let the "no media" status of one directory leak to the remaining files and directories in the same parent. Bug: 4364077 Change-Id: I2b04b872ece69441387c7fa579441a53f6f358d3 Signed-off-by: Mike Lockwood --- media/libmedia/MediaScanner.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/media/libmedia/MediaScanner.cpp b/media/libmedia/MediaScanner.cpp index 4e2217588f351..28c8642687d90 100644 --- a/media/libmedia/MediaScanner.cpp +++ b/media/libmedia/MediaScanner.cpp @@ -135,20 +135,21 @@ status_t MediaScanner::doProcessDirectory( } if (type == DT_REG || type == DT_DIR) { if (type == DT_DIR) { + bool childNoMedia = noMedia; // set noMedia flag on directories with a name that starts with '.' // for example, the Mac ".Trashes" directory if (name[0] == '.') - noMedia = true; + childNoMedia = true; // report the directory to the client if (stat(path, &statbuf) == 0) { - client.scanFile(path, statbuf.st_mtime, 0, true, noMedia); + client.scanFile(path, statbuf.st_mtime, 0, true, childNoMedia); } // and now process its contents strcat(fileSpot, "/"); int err = doProcessDirectory(path, pathRemaining - nameLength - 1, client, - noMedia, exceptionCheck, exceptionEnv); + childNoMedia, exceptionCheck, exceptionEnv); if (err) { // pass exceptions up - ignore other errors if (exceptionCheck && exceptionCheck(exceptionEnv)) goto failure;