Skip to content

Commit 42cd805

Browse files
author
Fastace
committed
Fix:修复文件恢复页面分组逻辑
1 parent a4e7444 commit 42cd805

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

source/feature/main/restore/src/main/kotlin/com/xayah/feature/main/restore/ResticFilesRestoreViewModel.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,21 @@ class ResticFilesRestoreViewModel @Inject constructor(
4747
try {
4848
val files = resticRepo.listBackedUpFiles(repoPath, password)
4949

50-
// 按路径分组,确保唯一性
50+
// 按媒体名称+前缀路径+时间戳分组
5151
val groupedByPath = files
52-
.groupBy { "${it.fullPath}-${it.timestamp}" }
53-
.map { (key, backups) ->
54-
val first = backups.first()
52+
.groupBy {
53+
// 提取前缀路径(去掉最后一层)
54+
val prefixPath = it.fullPath.substringBeforeLast("/")
55+
Triple(it.mediaName, prefixPath, it.timestamp)
56+
}
57+
.map { (groupKey, backups) ->
58+
val (mediaName, prefixPath, timestamp) = groupKey
5559
ResticFileBackupGroup(
56-
mediaName = first.mediaName,
57-
fullPath = first.fullPath,
58-
timestamp = first.timestamp,
59-
backups = backups.sortedBy { it.dataType.type }
60+
mediaName = mediaName,
61+
fullPath = prefixPath, // 使用前缀路径用于分组逻辑
62+
timestamp = timestamp,
63+
backups = backups, // 直接使用backups
64+
mediaLabel = mediaName
6065
)
6166
}
6267
.sortedByDescending { it.timestamp }

0 commit comments

Comments
 (0)