Error Message in ScanCsv hinzugefügt
This commit is contained in:
parent
8b052bc038
commit
3a0cfb2966
|
|
@ -47,15 +47,14 @@ func NewElioDateiFoo(lookUpDir string, process ElioHandleFunc) *ElioDateiFoo {
|
||||||
// Warenhausnamen in eine eine Hashmap ablegen. Dopplungen mit dem spätesten Zeitpunkt behalten.
|
// Warenhausnamen in eine eine Hashmap ablegen. Dopplungen mit dem spätesten Zeitpunkt behalten.
|
||||||
// Veraltete Dateien mit Präfix no-import und Postifx .old benennen.
|
// Veraltete Dateien mit Präfix no-import und Postifx .old benennen.
|
||||||
// Gültige Dateinamen zur Extraktion in Closure übergeben.
|
// Gültige Dateinamen zur Extraktion in Closure übergeben.
|
||||||
func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) {
|
func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData) error {
|
||||||
files, err := os.ReadDir(f.lookUpDir)
|
files, err := os.ReadDir(f.lookUpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
filemap := make(map[string]filedata)
|
filemap := make(map[string]filedata)
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
fmt.Printf("Lese Datei: %s\n", file)
|
|
||||||
if !strings.Contains(file.Name(), FileExt) {
|
if !strings.Contains(file.Name(), FileExt) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +70,7 @@ func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData)
|
||||||
if tl.Unix() >= value.dt.Unix() {
|
if tl.Unix() >= value.dt.Unix() {
|
||||||
err := os.Rename(f.lookUpDir+"/"+value.filename, f.lookUpDir+"/"+"no-import-"+value.filename+".old")
|
err := os.Rename(f.lookUpDir+"/"+value.filename, f.lookUpDir+"/"+"no-import-"+value.filename+".old")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Datei %s konnte nicht umbenannt werden!!!", value.filename)
|
return fmt.Errorf("Datei %s konnte nicht umbenannt werden!!!", value.filename)
|
||||||
}
|
}
|
||||||
filemap[warehouse] = filedata{filename: file.Name(), dt: tl}
|
filemap[warehouse] = filedata{filename: file.Name(), dt: tl}
|
||||||
}
|
}
|
||||||
|
|
@ -91,4 +90,5 @@ func (f *ElioDateiFoo) ScanCsv(ctx context.Context, data chan<- CountryCsvData)
|
||||||
f.mu.Unlock()
|
f.mu.Unlock()
|
||||||
f.process(ctx, v.filename, data)
|
f.process(ctx, v.filename, data)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue