Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksanford committed Oct 17, 2024
1 parent a888d0a commit ce4600f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions data/capture_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func TestCaptureBufferReader(t *testing.T) {

// Path() is the same as the first paramenter passed to NewCaptureBuffer
test.That(t, b.Path(), test.ShouldResemble, tmpDir)
test.That(t, b.MetaData, test.ShouldResemble, readImageCaptureMetadata)
test.That(t, b.metaData, test.ShouldResemble, readImageCaptureMetadata)

now := time.Now()
timeRequested := timestamppb.New(now.UTC())
Expand Down Expand Up @@ -689,7 +689,7 @@ func NickTest(t *testing.T) {

// Path() is the same as the first paramenter passed to NewCaptureBuffer
test.That(t, b.Path(), test.ShouldResemble, tmpDir)
test.That(t, b.MetaData, test.ShouldResemble, readImageCaptureMetadata)
test.That(t, b.metaData, test.ShouldResemble, readImageCaptureMetadata)

now := time.Now()
timeRequested := timestamppb.New(now.UTC())
Expand Down Expand Up @@ -725,7 +725,7 @@ func NickTest(t *testing.T) {
test.That(t, err, test.ShouldBeError, io.EOF)
}

// nolint
//nolint
func getCaptureFiles(dir string) (dcFiles, progFiles []string) {
_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions data/capture_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,19 @@ func getDataType(methodName string) v1.DataType {

// SensorDataFromCaptureFilePath returns all readings in the file at filePath.
// NOTE: (Nick S) At time of writing this is only used in tests.
//func SensorDataFromCaptureFilePath(filePath string) ([]*v1.SensorData, error) {
// //nolint:gosec
// f, err := os.Open(filePath)
// if err != nil {
// return nil, err
// }
// dcFile, err := NewCaptureFile(f)
// if err != nil {
// return nil, err
// }

// return SensorDataFromCaptureFile(dcFile)
//}
func SensorDataFromCaptureFilePath(filePath string) ([]*v1.SensorData, error) {
//nolint:gosec
f, err := os.Open(filePath)
if err != nil {
return nil, err
}
dcFile, err := NewCaptureFile(f)
if err != nil {
return nil, err
}

return SensorDataFromCaptureFile(dcFile)
}

// SensorDataFromCaptureFile returns all readings in f.
func SensorDataFromCaptureFile(f *CaptureFile) ([]*v1.SensorData, error) {
Expand Down
2 changes: 1 addition & 1 deletion services/datamanager/builtin/builtin_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ func getCapturedData(filePaths []string) (int, []*v1.SensorData, error) {
if err != nil {
return 0, nil, err
}
dcFile, err := data.ReadCaptureFile(osFile)
dcFile, err := data.NewCaptureFile(osFile)
if err != nil {
return 0, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion services/datamanager/builtin/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func collectorConfigDescription(
}

func targetDir(captureDir string, collectorConfig datamanager.DataCaptureConfig) string {
return data.CaptureFilePathWithReplacedReservedChars(
return data.FilePathWithReplacedReservedChars(
filepath.Join(captureDir, collectorConfig.Name.API.String(),
collectorConfig.Name.ShortName(), collectorConfig.Method))
}
Expand Down
2 changes: 1 addition & 1 deletion services/datamanager/builtin/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (s *Sync) syncFile(config Config, filePath string) {
}

func (s *Sync) syncDataCaptureFile(f *os.File, captureDir string, logger logging.Logger) {
captureFile, err := data.ReadCaptureFile(f)
captureFile, err := data.NewCaptureFile(f)
// if you can't read the capture file's metadata field, close & move it to the failed directory
if err != nil {
cause := errors.Wrap(err, "ReadCaptureFile failed")
Expand Down

0 comments on commit ce4600f

Please sign in to comment.