Skip to content

Commit

Permalink
Fix infinite recursion bug and update text to reflect that deleted fi…
Browse files Browse the repository at this point in the history
…les are found
  • Loading branch information
Jeremy Erickson committed Dec 5, 2013
1 parent 914a686 commit bd6309d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gmail.jerickson314.sdscanner"
android:versionCode="5"
android:versionName="1.4">
android:versionCode="6"
android:versionName="1.5">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
Expand Down
4 changes: 2 additions & 2 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<string name="button_start">Start Rescan</string>
<string name="database_proc">Examined</string>
<string name="delete_proc">Removed reference to</string>
<string name="db_label">Will also check existing media database for updated files.</string>
<string name="db_error_failure">Encountered error reading media database, and might miss updated files or rescan up-to-date files.</string>
<string name="db_label">Will also check existing media database for updated or deleted files.</string>
<string name="db_error_failure">Encountered error reading media database, and might miss updated or deleted files or rescan up-to-date files.</string>
<string name="db_error_recovered">Encountered error reading media database, but recovered.</string>
<string name="db_error_retrying">Encountered error reading media database. Retrying in 1 second...</string>
<string name="final_proc">Processed</string>
Expand Down
10 changes: 7 additions & 3 deletions src/com/gmail/jerickson314/sdscanner/ScanFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit bd6309d

Please sign in to comment.