Fix file filter and reduce it down to 1 line.
This commit is contained in:
parent
cc421c1435
commit
2252a5397d
@ -1,34 +0,0 @@
|
|||||||
package mineplex.chatsnap;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileFilter;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author iKeirNez
|
|
||||||
*/
|
|
||||||
public class ChatSnapFileFilter implements FileFilter
|
|
||||||
{
|
|
||||||
private static final String FILE_EXTENSION = ".json";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean accept(File file)
|
|
||||||
{
|
|
||||||
String fileName = file.getName();
|
|
||||||
|
|
||||||
if (file.isFile() && fileName.endsWith(FILE_EXTENSION))
|
|
||||||
{
|
|
||||||
String uuid = fileName.substring(0, fileName.length() - FILE_EXTENSION.length());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// this will trigger the catch block if invalid
|
|
||||||
UUID.fromString(uuid);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ import java.util.logging.Logger;
|
|||||||
*/
|
*/
|
||||||
public class PurgeTask implements Runnable
|
public class PurgeTask implements Runnable
|
||||||
{
|
{
|
||||||
private static final FileFilter FILE_FILTER = new ChatSnapFileFilter();
|
private static final FileFilter FILE_FILTER = file -> file.isFile() && file.getName().endsWith(".json");
|
||||||
|
|
||||||
private final File _dataDir;
|
private final File _dataDir;
|
||||||
private final Logger _logger;
|
private final Logger _logger;
|
||||||
|
Loading…
Reference in New Issue
Block a user