From bd6309d85d46cd0e9dd5e804cd06ac18a4496410 Mon Sep 17 00:00:00 2001 From: Jeremy Erickson Date: Thu, 5 Dec 2013 08:56:28 -0500 Subject: [PATCH] Fix infinite recursion bug and update text to reflect that deleted files are found --- AndroidManifest.xml | 4 ++-- res/values/strings.xml | 4 ++-- src/com/gmail/jerickson314/sdscanner/ScanFragment.java | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 81eeae4..7b6ed94 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="6" + android:versionName="1.5"> diff --git a/res/values/strings.xml b/res/values/strings.xml index 85cf8da..37acadf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5,8 +5,8 @@ Start Rescan Examined Removed reference to - Will also check existing media database for updated files. - Encountered error reading media database, and might miss updated files or rescan up-to-date files. + Will also check existing media database for updated or deleted files. + Encountered error reading media database, and might miss updated or deleted files or rescan up-to-date files. Encountered error reading media database, but recovered. Encountered error reading media database. Retrying in 1 second... Processed diff --git a/src/com/gmail/jerickson314/sdscanner/ScanFragment.java b/src/com/gmail/jerickson314/sdscanner/ScanFragment.java index 1dd4894..a6ac6aa 100644 --- a/src/com/gmail/jerickson314/sdscanner/ScanFragment.java +++ b/src/com/gmail/jerickson314/sdscanner/ScanFragment.java @@ -234,16 +234,20 @@ public int getId() { private void recursiveAddFiles(File file) throws IOException { + if (mFilesToProcess.contains(file)) { + // Avoid infinite recursion caused by symlinks. + return; + } + mFilesToProcess.add(file); if (file.isDirectory()) { boolean nomedia = new File(file, ".nomedia").exists(); // Only recurse downward if not blocked by nomedia. if (!nomedia) { for (File nextFile : file.listFiles()) { - recursiveAddFiles(nextFile); + recursiveAddFiles(nextFile.getCanonicalFile()); } } } - mFilesToProcess.add(file.getCanonicalFile()); } protected void dbOneTry() { @@ -303,7 +307,7 @@ else if (currentItem % reportFreq == 0) { @Override protected Void doInBackground(File... files) { try { - recursiveAddFiles(files[0]); + recursiveAddFiles(files[0].getCanonicalFile()); } catch (IOException Ex) { // Do nothing.