[android] Catch exceptions in getDirSizeRecursively()
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
parent
6278efaf44
commit
01a3e0b456
1 changed files with 15 additions and 8 deletions
|
@ -252,17 +252,24 @@ public class StorageUtils
|
|||
|
||||
public static long getDirSizeRecursively(File file, FilenameFilter fileFilter)
|
||||
{
|
||||
if (file.isDirectory())
|
||||
try
|
||||
{
|
||||
long dirSize = 0;
|
||||
for (File child : file.listFiles())
|
||||
dirSize += getDirSizeRecursively(child, fileFilter);
|
||||
if (file.isDirectory())
|
||||
{
|
||||
long dirSize = 0;
|
||||
for (File child : file.listFiles())
|
||||
dirSize += getDirSizeRecursively(child, fileFilter);
|
||||
|
||||
return dirSize;
|
||||
return dirSize;
|
||||
}
|
||||
|
||||
if (fileFilter.accept(file.getParentFile(), file.getName()))
|
||||
return file.length();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.e(TAG, "Can't calculate file or directory size", e);
|
||||
}
|
||||
|
||||
if (fileFilter.accept(file.getParentFile(), file.getName()))
|
||||
return file.length();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Reference in a new issue