Skip to content

Commit

Permalink
Do not skip symlinks, on Android 6 it prevents finding dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
itkach committed Dec 24, 2015
1 parent 5637152 commit 103e1dc
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions src/itkach/aard2/DictionaryFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ private List<File> scanDir(File dir) {
Log.d(T, String.format("%s is excluded", absolutePath));
return Collections.emptyList();
}
boolean symlink = false;
try {
symlink = isSymlink(dir);
} catch (IOException e) {
Log.e(T,
String.format("Failed to check if %s is symlink",
dir.getAbsolutePath()));
}

if (symlink) {
Log.d(T, String.format("%s is a symlink", absolutePath));
return Collections.emptyList();
}

if (dir.isHidden()) {
Log.d(T, String.format("%s is hidden", absolutePath));
Expand All @@ -78,34 +65,24 @@ private List<File> scanDir(File dir) {
break;
}
File file = files[i];
Log.d(T, "Considering " + file.getAbsolutePath());
if (file.isDirectory()) {
Log.d(T, "Directory: " + file.getAbsolutePath());
candidates.addAll(scanDir(file));
} else {
if (!file.isHidden() && file.isFile()) {
Log.d(T, "Candidate: " + file.getAbsolutePath());
candidates.add(file);
}
else {
Log.d(T, "Hidden or not a file: " + file.getAbsolutePath());
}
}
}
}
return candidates;
}

private static boolean isSymlink(File file) throws IOException {
File fileInCanonicalDir = null;
if (file.getParent() == null) {
fileInCanonicalDir = file;
} else {
File canonicalDir = file.getParentFile().getCanonicalFile();
fileInCanonicalDir = new File(canonicalDir, file.getName());
}
if (fileInCanonicalDir.getCanonicalFile().equals(
fileInCanonicalDir.getAbsoluteFile())) {
return false;
} else {
return true;
}
}

synchronized List<SlobDescriptor> findDictionaries() {
cancelRequested = false;
Log.d(T, "starting dictionary discovery");
Expand Down

0 comments on commit 103e1dc

Please sign in to comment.