You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
802 B

6 years ago
  1. package filer2
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/msgqueue"
  4. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  5. )
  6. func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry) {
  7. var key string
  8. if oldEntry != nil {
  9. key = string(oldEntry.FullPath)
  10. } else if newEntry != nil {
  11. key = string(newEntry.FullPath)
  12. } else {
  13. return
  14. }
  15. if msgqueue.Queue != nil {
  16. msgqueue.Queue.SendMessage(
  17. key,
  18. &filer_pb.EventNotification{
  19. OldEntry: toProtoEntry(oldEntry),
  20. NewEntry: toProtoEntry(newEntry),
  21. },
  22. )
  23. }
  24. }
  25. func toProtoEntry(entry *Entry) *filer_pb.Entry {
  26. if entry == nil {
  27. return nil
  28. }
  29. return &filer_pb.Entry{
  30. Name: string(entry.FullPath),
  31. IsDirectory: entry.IsDirectory(),
  32. Attributes: EntryAttributeToPb(entry),
  33. Chunks: entry.Chunks,
  34. }
  35. }