mirror of https://github.com/halo-dev/halo
Remove redundant try clause
parent
35ab8407d8
commit
b28eeb2657
|
@ -178,22 +178,20 @@ public class BackupServiceImpl implements BackupService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BackupDTO> listHaloBackups() {
|
public List<BackupDTO> listHaloBackups() {
|
||||||
try {
|
// Build backup dto
|
||||||
// Build backup dto
|
try (Stream<Path> subPathStream = Files.list(Paths.get(haloProperties.getBackupDir()))) {
|
||||||
try (Stream<Path> subPathStream = Files.list(Paths.get(haloProperties.getBackupDir()))) {
|
return subPathStream
|
||||||
return subPathStream
|
.filter(backupPath -> StringUtils.startsWithIgnoreCase(backupPath.getFileName().toString(), HaloConst.HALO_BACKUP_PREFIX))
|
||||||
.filter(backupPath -> StringUtils.startsWithIgnoreCase(backupPath.getFileName().toString(), HaloConst.HALO_BACKUP_PREFIX))
|
.map(this::buildBackupDto)
|
||||||
.map(this::buildBackupDto)
|
.sorted((leftBackup, rightBackup) -> {
|
||||||
.sorted((leftBackup, rightBackup) -> {
|
// Sort the result
|
||||||
// Sort the result
|
if (leftBackup.getUpdateTime() < rightBackup.getUpdateTime()) {
|
||||||
if (leftBackup.getUpdateTime() < rightBackup.getUpdateTime()) {
|
return 1;
|
||||||
return 1;
|
} else if (leftBackup.getUpdateTime() > rightBackup.getUpdateTime()) {
|
||||||
} else if (leftBackup.getUpdateTime() > rightBackup.getUpdateTime()) {
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
return 0;
|
||||||
return 0;
|
}).collect(Collectors.toList());
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ServiceException("Failed to fetch backups", e);
|
throw new ServiceException("Failed to fetch backups", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue