Skip to content

Commit

Permalink
Remove malformed filenames from concat operation
Browse files Browse the repository at this point in the history
  • Loading branch information
seanavery committed Oct 4, 2024
1 parent 4c26696 commit d3ec3a5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cam/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,24 @@ func getSortedFiles(path string) ([]string, error) {
if err != nil {
return nil, err
}
var filePaths []string
var validFilePaths []string
for _, file := range files {
filePaths = append(filePaths, filepath.Join(path, file.Name()))
filePath := filepath.Join(path, file.Name())
_, err := extractDateTimeFromFilename(filePath)
if err == nil {
validFilePaths = append(validFilePaths, filePath)
}
}
sort.Slice(filePaths, func(i, j int) bool {
timeI, errI := extractDateTimeFromFilename(filePaths[i])
timeJ, errJ := extractDateTimeFromFilename(filePaths[j])
sort.Slice(validFilePaths, func(i, j int) bool {
timeI, errI := extractDateTimeFromFilename(validFilePaths[i])
timeJ, errJ := extractDateTimeFromFilename(validFilePaths[j])
if errI != nil || errJ != nil {
return false
}
return timeI.Before(timeJ)
})

return filePaths, nil
return validFilePaths, nil
}

// extractDateTimeFromFilename extracts the date and time from the filename.
Expand Down

0 comments on commit d3ec3a5

Please sign in to comment.