mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow null directories in directory deletion methods.
This commit is contained in:
parent
83db4e6a10
commit
79307923ad
1 changed files with 15 additions and 9 deletions
|
@ -129,22 +129,28 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteDirectory(File directory) {
|
public static void deleteDirectory(File directory) {
|
||||||
deleteInDirectory(directory);
|
if (directory != null) {
|
||||||
directory.delete();
|
deleteInDirectory(directory);
|
||||||
|
directory.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteInDirectory(File directory) {
|
public static void deleteInDirectory(File directory) {
|
||||||
deleteInDirectoryApartFrom(directory);
|
if (directory != null) {
|
||||||
|
deleteInDirectoryApartFrom(directory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
||||||
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
if (directory != null) {
|
||||||
for (File file : directory.listFiles()) {
|
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
||||||
if (!excluded.contains(file.getName())) {
|
for (File file : directory.listFiles()) {
|
||||||
if (file.isDirectory()) {
|
if (!excluded.contains(file.getName())) {
|
||||||
deleteInDirectory(file);
|
if (file.isDirectory()) {
|
||||||
|
deleteInDirectory(file);
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
}
|
}
|
||||||
file.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue