File tree Expand file tree Collapse file tree
source/feature/main/restore/src/main/kotlin/com/xayah/feature/main/restore Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments