Closed GoogleCodeExporter closed 9 years ago
Could you please re-attach the full stack - the one you attached is blank.
And my first guess - the user has a link-loop in their filesystem. Directory A
has a folder B and in that folder there is a link to Directory A. This causes
calculateDirectorySize to infinite loop. We should catch this situation if
possible.
Original comment by kurtzm...@gmail.com
on 23 Mar 2011 at 2:05
Original comment by kurtzm...@gmail.com
on 23 Mar 2011 at 2:05
Thank you - that stack certainly looks like an infinite loop. It would be nice
to confirm if this user had an directory loop because I cannot seem to create a
symbolic link on my sdcard (even in the emulator).
But assuming it is a directory loop, then this is apparently a problem with no
easy solution in Java. There is no direct isSymbolicLink() in java.io so the
best we have is getCanonicalPath(). There are a few implementations that use
this to implement a isSymbolicLink() such as the one from apache commons (see
http://stackoverflow.com/questions/813710/java-1-6-determine-symbolic-links).
In our case, what we really need is a way to know if the directory we are about
to traverse has the same parent root as our current directory. So I think we
can do something like:
private boolean isSymbolicDirectoryLink(final String aParentCanonicalPath,
final File aDirectory) {
try {
final String canonicalParentPath = aDirectory.getCanonicalFile().getParent();
return aParentCanonicalPath.equals(canonicalParentPath);
} catch (IOException e) {
return false;
}
}
Thoughts anyone?
Original comment by kurtzm...@gmail.com
on 26 Mar 2011 at 3:07
Issue 194 has been merged into this issue.
Original comment by neilboyd
on 31 Mar 2011 at 2:36
I am going to commit a solution for this. Please report back and let us know if
it worked!
Original comment by kurtzm...@gmail.com
on 1 Apr 2011 at 12:34
This issue was updated by revision r910.
Adds symbolic link checking before descending into a new directory in
calculateDirectorySize
Original comment by kurtzm...@gmail.com
on 1 Apr 2011 at 12:34
Original comment by kurtzm...@gmail.com
on 1 Apr 2011 at 12:34
This issue will be closed. The code has been running for a while and it
functionally appears to be doing its job.
Original comment by kurtzm...@gmail.com
on 3 Jun 2011 at 9:31
Original issue reported on code.google.com by
bob.hage...@gmail.com
on 22 Mar 2011 at 2:21Attachments: