func (repo *RepositoryConfig) PurgeBefore(kind MediaKind, then time.Time) {
	for _, camera := range System.Cameras() {
		dir := repo.dirFor(camera.ID, kind)
		f, err := os.Open(dir)
		if err != nil {
			panic(err)
		}
		defer f.Close()
		entries, err := f.Readdir(0)
		if err != nil {
			panic(err)
		}
		for _, entry := range entries {
			if entry.IsDir() {
				log.Warn("RepositoryConfig.PurgeBefore", fmt.Sprintf("encountered dir '%s' where it shouldn't be", dir))
				continue
			}
			if entry.ModTime().Before(then) {
				file := repo.canonFile(filepath.Join(dir, entry.Name()))
				if err := os.Remove(file); err != nil {
					panic(err)
				}
			}
		}
	}
}
// PurgeBefore removes all images stored prior to a given time. This is used to enforce a rolling
// window of images.
PurgeBefore removes all images stored prior to a given time. This is used to enforce a rolling
window of images.
// PurgeBefore removes all images stored prior to a given time . This is used to enforce a rolling // window of images .
func (repo *RepositoryConfig) PurgeBefore(kind MediaKind, then time.Time) {
	for _, camera := range System.Cameras() {
		dir := repo.dirFor(camera.ID, kind)
		f, err := os.Open(dir)
		if err != nil {
			panic(err)
		}
		defer f.Close()
		entries, err := f.Readdir(0)
		if err != nil {
			panic(err)
		}
		for _, entry := range entries {
			if entry.IsDir() {
				log.Warn("RepositoryConfig.PurgeBefore", fmt.Sprintf("encountered dir '%s' where it shouldn't be", dir))
				continue
			}
			if entry.ModTime().Before(then) {
				file := repo.canonFile(filepath.Join(dir, entry.Name()))
				if err := os.Remove(file); err != nil {
					panic(err)
				}
			}
		}
	}
}
func ( repo * RepositoryConfig ) PurgeBefore ( kind MediaKind , then time . Time ) { for _ , camera := range System . Cameras ( ) { dir := repo . dirFor ( camera . ID , kind ) f , err := os . Open ( dir ) if err != nil { panic ( err ) } defer f . Close ( ) entries , err := f . Readdir ( 0 ) if err != nil { panic ( err ) } for _ , entry := range entries { if entry . IsDir ( ) { log . Warn ( " " , fmt . Sprintf ( " " , dir ) ) continue } if entry . ModTime ( ) . Before ( then ) { file := repo . canonFile ( filepath . Join ( dir , entry . Name ( ) ) ) if err := os . Remove ( file ) ; err != nil { panic ( err ) } } } } }
PurgeBefore removes all images stored prior to a given time.
PurgeBefore removes all images stored prior to a given time .