-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EVENT: Rename event files. Add structure to generated events.
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.