Replace File.delete with Files.delete

This commit is contained in:
AsamK 2021-10-25 15:33:40 +02:00
parent 4e69b34efe
commit fc5af35a04

View file

@ -30,6 +30,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.HashMap; import java.util.HashMap;
@ -122,7 +123,11 @@ public class GroupStore {
} }
final var groupFileLegacy = getGroupV2FileLegacy(group.getGroupId()); final var groupFileLegacy = getGroupV2FileLegacy(group.getGroupId());
if (groupFileLegacy.exists()) { if (groupFileLegacy.exists()) {
groupFileLegacy.delete(); try {
Files.delete(groupFileLegacy.toPath());
} catch (IOException e) {
logger.error("Failed to delete legacy group file {}: {}", groupFileLegacy, e.getMessage());
}
} }
} catch (IOException e) { } catch (IOException e) {
logger.warn("Failed to cache group, ignoring: {}", e.getMessage()); logger.warn("Failed to cache group, ignoring: {}", e.getMessage());