feature: Extra file info using onfileindir (#293)
This commit is contained in:
parent
500419307b
commit
d6cb634824
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"github.com/OliveTin/OliveTin/internal/executor"
|
"github.com/OliveTin/OliveTin/internal/executor"
|
||||||
"github.com/OliveTin/OliveTin/internal/filehelper"
|
"github.com/OliveTin/OliveTin/internal/filehelper"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"os"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
|
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) {
|
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{
|
req := &executor.ExecutionRequest{
|
||||||
ActionTitle: action.Title,
|
ActionTitle: action.Title,
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
Tags: []string{"fileindir"},
|
Tags: []string{"fileindir"},
|
||||||
Arguments: map[string]string{
|
Arguments: args,
|
||||||
"filepath": filepath.Base(path),
|
|
||||||
"filename": filepath.Base(path),
|
|
||||||
"filedir": filepath.Dir(path),
|
|
||||||
"fileext": filepath.Ext(path),
|
|
||||||
|
|
||||||
},
|
|
||||||
AuthenticatedUser: &acl.AuthenticatedUser{
|
AuthenticatedUser: &acl.AuthenticatedUser{
|
||||||
Username: "fileindir",
|
Username: "fileindir",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue