mirror of https://github.com/halo-dev/halo
Fix file list bug
parent
b7cf5576af
commit
35ab8407d8
|
@ -39,6 +39,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Backup service implementation.
|
* Backup service implementation.
|
||||||
|
@ -179,7 +180,8 @@ public class BackupServiceImpl implements BackupService {
|
||||||
public List<BackupDTO> listHaloBackups() {
|
public List<BackupDTO> listHaloBackups() {
|
||||||
try {
|
try {
|
||||||
// Build backup dto
|
// Build backup dto
|
||||||
return Files.list(Paths.get(haloProperties.getBackupDir()))
|
try (Stream<Path> subPathStream = Files.list(Paths.get(haloProperties.getBackupDir()))) {
|
||||||
|
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) -> {
|
||||||
|
@ -191,6 +193,7 @@ public class BackupServiceImpl implements BackupService {
|
||||||
}
|
}
|
||||||
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