[Android] Do not scan again if same canonical path.
Sébastien Toque
git at videolan.org
Thu Aug 30 20:25:25 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Thu Aug 30 19:50:05 2012 +0200| [1e7a2fcd9d09f17fa665de69c71e549df4dd223c] | committer: Sébastien Toque
Do not scan again if same canonical path.
This prevent duplicates in media library because of symlinks.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=1e7a2fcd9d09f17fa665de69c71e549df4dd223c
---
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index 2286e8b..df66b77 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -22,6 +22,7 @@ package org.videolan.vlc;
import java.io.File;
import java.io.FileFilter;
+import java.io.IOException;
import java.lang.Thread.State;
import java.util.ArrayList;
import java.util.HashMap;
@@ -153,6 +154,7 @@ public class MediaLibrary {
private class GetMediaItemsRunnable implements Runnable {
private final Stack<File> directories = new Stack<File>();
+ private final HashSet<String> directoriesScanned = new HashSet<String>();
private Context mContext;
public GetMediaItemsRunnable(Context context) {
@@ -200,10 +202,22 @@ public class MediaLibrary {
// Count total files, and stack them
while (!directories.isEmpty()) {
File dir = directories.pop();
+ String dirPath = dir.getAbsolutePath();
File[] f = null;
+ // Do not scan again if same canonical path
+ try {
+ dirPath = dir.getCanonicalPath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ if (directoriesScanned.contains(dirPath))
+ continue;
+ else
+ directoriesScanned.add(dirPath);
+
// Do no scan media in .nomedia folders
- if (new File(dir.getAbsolutePath() + "/.nomedia").exists()) {
+ if (new File(dirPath + "/.nomedia").exists()) {
continue;
}
More information about the Android
mailing list