|
|
@@ -6,6 +6,8 @@ import (
|
|
|
"github.com/OliveTin/OliveTin/internal/executor"
|
|
|
"github.com/OliveTin/OliveTin/internal/filehelper"
|
|
|
"path/filepath"
|
|
|
+ "os"
|
|
|
+ "fmt"
|
|
|
)
|
|
|
|
|
|
func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
|
|
|
@@ -25,17 +27,27 @@ func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
|
|
|
}
|
|
|
|
|
|
func scheduleExec(action *config.Action, cfg *config.Config, ex *executor.Executor, path string) {
|
|
|
+ args := map[string]string{
|
|
|
+ "filepath": path,
|
|
|
+ "filename": filepath.Base(path),
|
|
|
+ "filedir": filepath.Dir(path),
|
|
|
+ "fileext": filepath.Ext(path),
|
|
|
+ }
|
|
|
+
|
|
|
+ if stat, err := os.Stat(path); err == nil {
|
|
|
+ args["filesizebytes"] = fmt.Sprintf("%v", stat.Size())
|
|
|
+ args["filemode"] = fmt.Sprintf("%#o", stat.Mode())
|
|
|
+ args["filemtime"] = fmt.Sprintf("%v", stat.ModTime())
|
|
|
+ args["fileisdir"] = fmt.Sprintf("%v", stat.IsDir())
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Printf("%+v", args)
|
|
|
+
|
|
|
req := &executor.ExecutionRequest{
|
|
|
ActionTitle: action.Title,
|
|
|
Cfg: cfg,
|
|
|
Tags: []string{"fileindir"},
|
|
|
- Arguments: map[string]string{
|
|
|
- "filepath": filepath.Base(path),
|
|
|
- "filename": filepath.Base(path),
|
|
|
- "filedir": filepath.Dir(path),
|
|
|
- "fileext": filepath.Ext(path),
|
|
|
-
|
|
|
- },
|
|
|
+ Arguments: args,
|
|
|
AuthenticatedUser: &acl.AuthenticatedUser{
|
|
|
Username: "fileindir",
|
|
|
},
|