Commit d64b1c07 authored by Geoffrey Métais's avatar Geoffrey Métais

List names instead of files to spare memory

parent 3b4e2d0a
......@@ -275,7 +275,7 @@ public class MediaLibrary {
int count = 0;
ArrayList<File> mediaToScan = new ArrayList<File>();
LinkedList<File> mediaToScan = new LinkedList<File>();
try {
LinkedList<String> dirsToIgnore = new LinkedList<String>();
// Count total files, and stack them
......@@ -307,17 +307,21 @@ public class MediaLibrary {
// Filter the extensions and the folders
try {
if ((f = dir.listFiles(mediaFileFilter)) != null) {
for (File file : f) {
if (file.isFile()) {
mediaToScan.add(file);
} else if (file.isDirectory()) {
directories.push(file);
String[] files = dir.list();
File file;
if (files != null){
for (String fileName : files){
file = new File(dirPath, fileName);
if (mediaFileFilter.accept(file)){
if (file.isFile())
mediaToScan.add(file);
else if (file.isDirectory())
directories.push(file);
}
file = null;
}
}
} catch (Exception e)
{
} catch (Exception e){
// listFiles can fail in OutOfMemoryError, go to the next folder
continue;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment