1
0
Fork 0
go-asink/events.go

45 lines
890 B
Go
Raw Normal View History

2013-02-11 23:16:19 -05:00
package main
2013-02-13 07:31:10 -05:00
import (
"time"
)
//event type
2013-02-11 23:16:19 -05:00
type EventType uint32
const (
2013-02-11 23:17:12 -05:00
UPDATE = 1 << iota
2013-02-11 23:16:19 -05:00
DELETE
)
2013-02-13 07:31:10 -05:00
//event status
type EventStatus uint32
const (
NOTICED = 1 << iota //watcher.go has been notified that a file changed
COPIED_TO_TMP //temporary version saved off
HASHED //hash taken of tmp file
CACHED //tmp file renamed to its hash
UPLOADED //tmp file has been successfully uploaded to storage
ON_SERVER //server has been successfully notified of event
)
2013-02-11 23:16:19 -05:00
type Event struct {
Id int64
LocalId int64
2013-02-13 07:31:10 -05:00
Type EventType
Status EventStatus
Path string
Hash string
Timestamp time.Time
InDB bool //defaults to false
2013-02-11 23:16:19 -05:00
}
func (e Event) IsUpdate() bool {
2013-02-11 23:17:12 -05:00
return e.Type&UPDATE == UPDATE
2013-02-11 23:16:19 -05:00
}
func (e Event) IsDelete() bool {
2013-02-11 23:17:12 -05:00
return e.Type&DELETE == DELETE
2013-02-11 23:16:19 -05:00
}