|
@ -6,6 +6,7 @@ import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
"os" |
|
|
"os" |
|
|
"strings" |
|
|
"strings" |
|
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle" |
|
@ -13,6 +14,8 @@ import ( |
|
|
"google.golang.org/protobuf/proto" |
|
|
"google.golang.org/protobuf/proto" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const cutoffTimeNewEmptyDir = 3 |
|
|
|
|
|
|
|
|
func (entry *Entry) IsInRemoteOnly() bool { |
|
|
func (entry *Entry) IsInRemoteOnly() bool { |
|
|
return len(entry.GetChunks()) == 0 && entry.RemoteEntry != nil && entry.RemoteEntry.RemoteSize > 0 |
|
|
return len(entry.GetChunks()) == 0 && entry.RemoteEntry != nil && entry.RemoteEntry.RemoteSize > 0 |
|
|
} |
|
|
} |
|
@ -28,6 +31,10 @@ func (entry *Entry) FileMode() (fileMode os.FileMode) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (entry *Entry) IsOlderDir() bool { |
|
|
|
|
|
return entry.IsDirectory && entry.Attributes != nil && entry.Attributes.Mime == "" && entry.Attributes.GetCrtime() <= time.Now().Unix()-cutoffTimeNewEmptyDir |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func ToFileIdObject(fileIdStr string) (*FileId, error) { |
|
|
func ToFileIdObject(fileIdStr string) (*FileId, error) { |
|
|
t, err := needle.ParseFileIdFromString(fileIdStr) |
|
|
t, err := needle.ParseFileIdFromString(fileIdStr) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -143,18 +150,22 @@ var ErrNotFound = errors.New("filer: no entry is found in filer store") |
|
|
func IsEmpty(event *SubscribeMetadataResponse) bool { |
|
|
func IsEmpty(event *SubscribeMetadataResponse) bool { |
|
|
return event.EventNotification.NewEntry == nil && event.EventNotification.OldEntry == nil |
|
|
return event.EventNotification.NewEntry == nil && event.EventNotification.OldEntry == nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func IsCreate(event *SubscribeMetadataResponse) bool { |
|
|
func IsCreate(event *SubscribeMetadataResponse) bool { |
|
|
return event.EventNotification.NewEntry != nil && event.EventNotification.OldEntry == nil |
|
|
return event.EventNotification.NewEntry != nil && event.EventNotification.OldEntry == nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func IsUpdate(event *SubscribeMetadataResponse) bool { |
|
|
func IsUpdate(event *SubscribeMetadataResponse) bool { |
|
|
return event.EventNotification.NewEntry != nil && |
|
|
return event.EventNotification.NewEntry != nil && |
|
|
event.EventNotification.OldEntry != nil && |
|
|
event.EventNotification.OldEntry != nil && |
|
|
event.Directory == event.EventNotification.NewParentPath && |
|
|
event.Directory == event.EventNotification.NewParentPath && |
|
|
event.EventNotification.NewEntry.Name == event.EventNotification.OldEntry.Name |
|
|
event.EventNotification.NewEntry.Name == event.EventNotification.OldEntry.Name |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func IsDelete(event *SubscribeMetadataResponse) bool { |
|
|
func IsDelete(event *SubscribeMetadataResponse) bool { |
|
|
return event.EventNotification.NewEntry == nil && event.EventNotification.OldEntry != nil |
|
|
return event.EventNotification.NewEntry == nil && event.EventNotification.OldEntry != nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func IsRename(event *SubscribeMetadataResponse) bool { |
|
|
func IsRename(event *SubscribeMetadataResponse) bool { |
|
|
return event.EventNotification.NewEntry != nil && |
|
|
return event.EventNotification.NewEntry != nil && |
|
|
event.EventNotification.OldEntry != nil && |
|
|
event.EventNotification.OldEntry != nil && |
|
|