mirror of https://github.com/halo-dev/halo
parent
694667fcf5
commit
36b3a2d3b4
|
@ -38,6 +38,7 @@ import java.nio.file.Paths;
|
|||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -192,15 +193,8 @@ public class BackupServiceImpl implements BackupService {
|
|||
return subPathStream
|
||||
.filter(backupPath -> StringUtils.startsWithIgnoreCase(backupPath.getFileName().toString(), HaloConst.HALO_BACKUP_PREFIX))
|
||||
.map(backupPath -> buildBackupDto(BACKUP_RESOURCE_BASE_URI, backupPath))
|
||||
.sorted((leftBackup, rightBackup) -> {
|
||||
// Sort the result
|
||||
if (leftBackup.getUpdateTime() < rightBackup.getUpdateTime()) {
|
||||
return 1;
|
||||
} else if (leftBackup.getUpdateTime() > rightBackup.getUpdateTime()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
.sorted(Comparator.comparingLong(BackupDTO::getUpdateTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException("Failed to fetch backups", e);
|
||||
}
|
||||
|
@ -317,15 +311,8 @@ public class BackupServiceImpl implements BackupService {
|
|||
return subPathStream
|
||||
.filter(backupPath -> StringUtils.startsWithIgnoreCase(backupPath.getFileName().toString(), HaloConst.HALO_DATA_EXPORT_PREFIX))
|
||||
.map(backupPath -> buildBackupDto(DATA_EXPORT_BASE_URI, backupPath))
|
||||
.sorted((leftBackup, rightBackup) -> {
|
||||
// Sort the result
|
||||
if (leftBackup.getUpdateTime() < rightBackup.getUpdateTime()) {
|
||||
return 1;
|
||||
} else if (leftBackup.getUpdateTime() > rightBackup.getUpdateTime()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
.sorted(Comparator.comparingLong(BackupDTO::getUpdateTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException("Failed to fetch exported data", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue