<commit_before>package omxplayer

import (
	log "github.com/Sirupsen/logrus"
	"os"
)

// removeFile removes the specified file. Errors are ignored.
func removeFile(path string) {
	log.WithFields(log.Fields{
		"path": path,
	}).Debug("omxplayer: removing file")
	os.Remove(path)
}<commit_msg>Implement a waitForFile function.<commit_after>package omxplayer

import (
	"fmt"
	log "github.com/Sirupsen/logrus"
	"os"
	"time"
)

// removeFile removes the specified file. Errors are ignored.
func removeFile(path string) {
	log.WithFields(log.Fields{
		"path": path,
	}).Debug("omxplayer: removing file")
	os.Remove(path)
}

// waitForFile waits for the specified file to exist before returning. If the an
// error, other than the file not existing, occurs, the error is returned. If,
// after 100 attempts, the file does not exist, an error is returned.
func waitForFile(path string) error {
	log.WithFields(log.Fields{
		"file": path,
	}).Debug("omxplayer: waiting for file")
	for i := 0; i < 100; i++ {
		_, err := os.Stat(path)
		if err == nil || !os.IsNotExist(err) {
			return err
		}
		time.Sleep(50 * time.Millisecond)
	}
	return fmt.Errorf("omxplayer: file does not exist: %s", path)
}
{'fraction_non_alphanumeric': 0.13215488215488216, 'fraction_numerical': 0.007575757575757576, 'mean_word_length': 4.1695652173913045, 'pattern_counts': {'":': 3, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '312094', 'n_tokens_mistral': 428, 'n_tokens_neox': 406, 'n_words': 126}