Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksanford committed Sep 6, 2024
1 parent f90261d commit b8c7661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion data/capture_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type CaptureFile struct {
}

// ReadCaptureFile creates a File struct from a passed os.File previously constructed using NewFile.
// TODO: Nick If the DataCaptureFile has metadata but no sensor data, what is returned?
func ReadCaptureFile(f *os.File) (*CaptureFile, error) {
if !IsDataCaptureFile(f) {
return nil, errors.Errorf("%s is not a data capture file", f.Name())
Expand Down
19 changes: 12 additions & 7 deletions services/datamanager/builtin/capture/file_count_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ import (
datasync "go.viam.com/rdk/services/datamanager/builtin/sync"
)

// fileCountLogger logs the number of completed capture files that
// are eligible to be synced in the capture directory.
// It excludes files in failed directories
// This is a temporary measure to provide some imperfect signal into what
// data capture files are eligible to be synced on the robot.
type fileCountLogger struct {
logger logging.Logger
workers *goutils.StoppableWorkers
logger logging.Logger
worker *goutils.StoppableWorkers
}

func newFileCountLogger(logger logging.Logger) *fileCountLogger {
return &fileCountLogger{
logger: logger,
workers: goutils.NewBackgroundStoppableWorkers(),
logger: logger,
worker: goutils.NewBackgroundStoppableWorkers(),
}
}

func (poller *fileCountLogger) reconfigure(captureDir string) {
poller.workers.Stop()
poller.workers = goutils.NewBackgroundStoppableWorkers(func(ctx context.Context) {
poller.worker.Stop()
poller.worker = goutils.NewBackgroundStoppableWorkers(func(ctx context.Context) {
t := time.NewTicker(captureDirSizeLogInterval)
defer t.Stop()
for {
Expand All @@ -45,7 +50,7 @@ func (poller *fileCountLogger) reconfigure(captureDir string) {
}

func (poller *fileCountLogger) close() {
poller.workers.Stop()
poller.worker.Stop()
}

func countFiles(ctx context.Context, captureDir string) int {
Expand Down

0 comments on commit b8c7661

Please sign in to comment.