(backup Backup, decompressor compression.Decompressor)
| 151 | } |
| 152 | |
| 153 | func GetPartitionedBackupFileNames(backup Backup, decompressor compression.Decompressor) ([][]string, error) { |
| 154 | // list all files in backup folder: |
| 155 | files, _, err := backup.Folder.GetSubFolder(backup.Name).ListFolder() |
| 156 | if err != nil { |
| 157 | return nil, fmt.Errorf("cannot list files in backup folder '%s' due to: %w", backup.Folder.GetPath(), err) |
| 158 | } |
| 159 | |
| 160 | // prepare lookup table: |
| 161 | fileNames := make(map[string]bool) |
| 162 | for _, file := range files { |
| 163 | filePath := path.Join(backup.Name, file.GetName()) |
| 164 | fileNames[filePath] = true |
| 165 | } |
| 166 | |
| 167 | result := make([][]string, 0) |
| 168 | partIdx := 0 |
| 169 | for { |
| 170 | nextPartitionFirstFile := GetPartitionedSteamMultipartName(backup.Name, decompressor.FileExtension(), partIdx, 0) |
| 171 | nextPartitionWholeFile := GetPartitionedStreamName(backup.Name, decompressor.FileExtension(), partIdx) |
| 172 | if fileNames[nextPartitionFirstFile] { |
| 173 | result = append(result, make([]string, 1)) |
| 174 | result[partIdx][0] = nextPartitionFirstFile |
| 175 | fileIdx := 1 |
| 176 | for { |
| 177 | nextPartitionFile := GetPartitionedSteamMultipartName(backup.Name, decompressor.FileExtension(), partIdx, fileIdx) |
| 178 | if fileNames[nextPartitionFile] { |
| 179 | result[partIdx] = append(result[partIdx], nextPartitionFile) |
| 180 | fileIdx++ |
| 181 | } else { |
| 182 | break |
| 183 | } |
| 184 | } |
| 185 | } else if fileNames[nextPartitionWholeFile] { |
| 186 | result = append(result, make([]string, 1)) |
| 187 | result[partIdx][0] = nextPartitionWholeFile |
| 188 | } else { |
| 189 | break |
| 190 | } |
| 191 | partIdx++ |
| 192 | } |
| 193 | |
| 194 | return result, nil |
| 195 | } |
no test coverage detected