Fixup cdrc to support freeswitch_csv type (ignore .files ending with .csv)

This commit is contained in:
DanB
2014-01-06 12:09:51 +01:00
parent caa2ed7776
commit 99a9b2c987
2 changed files with 7 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ import (
const (
CSV = "csv"
FS_CSV = "freeswitch_csv"
)
func NewCdrc(config *config.CGRConfig) (*Cdrc, error) {
@@ -125,8 +126,10 @@ func (self *Cdrc) processCdrDir() error {
engine.Logger.Info(fmt.Sprintf("<Cdrc> Parsing folder %s for CDR files.", self.cgrCfg.CdrcCdrInDir))
filesInDir, _ := ioutil.ReadDir(self.cgrCfg.CdrcCdrInDir)
for _, file := range filesInDir {
if err := self.processFile(path.Join(self.cgrCfg.CdrcCdrInDir, file.Name())); err != nil {
return err
if self.cgrCfg.CdrcCdrType!=FS_CSV || path.Ext(file.Name())!=".csv" {
if err := self.processFile(path.Join(self.cgrCfg.CdrcCdrInDir, file.Name())); err != nil {
return err
}
}
}
return nil
@@ -147,7 +150,7 @@ func (self *Cdrc) trackCDRFiles() (err error) {
for {
select {
case ev := <-watcher.Event:
if ev.IsCreate() { //&& path.Ext(ev.Name) != ".csv"
if ev.IsCreate() && (self.cgrCfg.CdrcCdrType!=FS_CSV || path.Ext(ev.Name)!=".csv") {
if err = self.processFile(ev.Name); err != nil {
return err
}

View File

@@ -60,7 +60,7 @@
# cdrs = 127.0.0.1:2022 # Address where to reach CDR server
# cdrs_method = http_cgr # Mechanism to use when posting CDRs on server <http_cgr>
# run_delay = 0 # Sleep interval in seconds between consecutive runs, 0 to use automation via inotify
# cdr_type = csv # CDR file format <csv>.
# cdr_type = csv # CDR file format <csv|freeswitch_csv>.
# cdr_in_dir = /var/log/cgrates/cdr/in/csv # Absolute path towards the directory where the CDRs are stored.
# cdr_out_dir = /var/log/cgrates/cdr/out/csv # Absolute path towards the directory where processed CDRs will be moved.
# cdr_source_id = freeswitch_csv # Free form field, tag identifying the source of the CDRs within CGRS database.