Skip to content

Commit

Permalink
WIP: Add regex support for linux too
Browse files Browse the repository at this point in the history
  • Loading branch information
Cian911 committed Mar 27, 2022
1 parent 0aa3c39 commit 951f1b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
4 changes: 4 additions & 0 deletions watcher/watcher_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (
"log"
"os"
"path/filepath"
"regexp"
"time"

"github.com/cian911/switchboard/event"
"github.com/cian911/switchboard/utils"
"github.com/fsnotify/fsnotify"
)

// TODO: Change this from an int to a bool
// Monitor for IN_CLOSE_WRITE events on these file exts
// A create event should immediatly follow
var specialWatchedFileExts = map[string]int{
Expand Down Expand Up @@ -65,6 +67,8 @@ type PathConsumer struct {
Destination string
// File extenstion
Ext string
// Regex Pattern
Pattern regexp.Regexp
}

// Receive takes a path and an event operation, determines its validity
Expand Down
22 changes: 0 additions & 22 deletions watcher/watcher_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,9 @@
package watcher

import (
"io/ioutil"
"testing"
"time"

"github.com/cian911/switchboard/event"
)

func TestObserve(t *testing.T) {
return true
}

func testEventSetup(op string, t *testing.T) *event.Event {
path := t.TempDir()
_, err := ioutil.TempFile(path, file)

if err != nil {
t.Fatalf("Unable to create temp file: %v", err)
}

return &event.Event{
File: file,
Path: path,
Destination: t.TempDir(),
Ext: ext,
Operation: op,
Timestamp: time.Now(),
}
}

0 comments on commit 951f1b1

Please sign in to comment.