do not index hidden files or folders.

This commit is contained in:
Adrian Ulrich 2018-10-22 21:03:24 +02:00
parent e3b878e69b
commit c6fedb9e17

View File

@ -426,6 +426,9 @@ public class MediaScanner implements Handler.Callback {
if (new File(dir, ".nomedia").exists())
return;
if (isDotfile(dir))
return;
File[] dirents = dir.listFiles();
if (dirents == null)
return;
@ -450,6 +453,9 @@ public class MediaScanner implements Handler.Callback {
if (isBlacklisted(file))
return false;
if (isDotfile(file))
return false;
long dbEntryMtime = mBackend.getColumnFromSongId(MediaLibrary.SongColumns.MTIME, songId) * 1000; // this is in unixtime -> convert to 'ms'
long songFlags = mBackend.getColumnFromSongId(MediaLibrary.SongColumns.FLAGS, songId);
long fileMtime = file.lastModified();
@ -646,6 +652,17 @@ public class MediaScanner implements Handler.Callback {
}
private static final Pattern sDotfilePattern = Pattern.compile("^\\..*$", Pattern.CASE_INSENSITIVE);
/**
* Returns true if the file is a hidden dotfile.
*
* @param file to inspect
* @return boolean
*/
private boolean isDotfile(File file) {
return sDotfilePattern.matcher(file.getName()).matches();
}
// MediaScanPlan describes how we are going to perform the media scan
class MediaScanPlan {
class Step {