Skip to content

Commit

Permalink
EVENT: Rename event files. Add structure to generated events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cian911 committed Dec 11, 2021
1 parent d4af193 commit dab560a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
31 changes: 31 additions & 0 deletions event/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package event

import (
"fmt"
"log"
"os"
)

type Event struct {
File string
Path string
Destination string
Ext string
Operation string
}

func (e *Event) Move() {
log.Printf("Moving e.Path: %s to %s/%s\n", e.Path, e.Destination, e.File)
err := os.Rename(e.Path, fmt.Sprintf("%s/%s", e.Destination, e.File))
if err != nil {
log.Fatalf("Unable to move file from { %s } to { %s }: %v", e.Path, e.Destination, err)
}
}

func (e *Event) IsValidEvent(ext string) bool {
if ext == e.Ext && e.Operation == "CREATE" {
return true
}

return false
}
File renamed without changes.
1 change: 0 additions & 1 deletion event/file_event_test.go

This file was deleted.

0 comments on commit dab560a

Please sign in to comment.