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.

38 lines
762 B

  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. msgqueue.Queue.SendMessage(
  16. key,
  17. &filer_pb.EventNotification{
  18. OldEntry: toProtoEntry(oldEntry),
  19. NewEntry: toProtoEntry(newEntry),
  20. },
  21. )
  22. }
  23. func toProtoEntry(entry *Entry) *filer_pb.Entry {
  24. if entry == nil {
  25. return nil
  26. }
  27. return &filer_pb.Entry{
  28. Name: string(entry.FullPath),
  29. IsDirectory: entry.IsDirectory(),
  30. Attributes: EntryAttributeToPb(entry),
  31. Chunks: entry.Chunks,
  32. }
  33. }