本文整理汇总了Golang中github.com/syncthing/syncthing/lib/protocol.FileInfo.IsInvalid方法的典型用法代码示例。如果您正苦于以下问题:Golang FileInfo.IsInvalid方法的具体用法?Golang FileInfo.IsInvalid怎么用?Golang FileInfo.IsInvalid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/syncthing/syncthing/lib/protocol.FileInfo
的用法示例。
在下文中一共展示了FileInfo.IsInvalid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addToLocalModel
// requires write lock on model.fmut before entry
// requires file does not exist in local model
func (m *Model) addToLocalModel(deviceID protocol.DeviceID, folder string, file protocol.FileInfo) {
if file.IsDeleted() {
if debug {
l.Debugln("peer", deviceID.String(), "has deleted file, doing nothing", file.Name)
}
return
}
if file.IsInvalid() {
if debug {
l.Debugln("peer", deviceID.String(), "has invalid file, doing nothing", file.Name)
}
return
}
if file.IsSymlink() {
if debug {
l.Debugln("peer", deviceID.String(), "has symlink, doing nothing", file.Name)
}
return
}
if debug && file.IsDirectory() {
l.Debugln("peer", deviceID.String(), "has directory, adding", file.Name)
} else if debug {
l.Debugln("peer", deviceID.String(), "has file, adding", file.Name)
}
m.treeCaches[folder].AddEntry(file)
m.addPeerForEntry(deviceID, folder, file)
}
示例2: walkAndHashFiles
//.........这里部分代码省略.........
return skip
}
// We always rehash symlinks as they have no modtime or
// permissions. We check if they point to the old target by
// checking that their existing blocks match with the blocks in
// the index.
target, targetType, err := symlinks.Read(p)
if err != nil {
if debug {
l.Debugln("readlink error:", p, err)
}
return skip
}
blocks, err := Blocks(strings.NewReader(target), w.BlockSize, 0, nil)
if err != nil {
if debug {
l.Debugln("hash link error:", p, err)
}
return skip
}
if w.CurrentFiler != nil {
// A symlink is "unchanged", if
// - it exists
// - it wasn't deleted (because it isn't now)
// - it was a symlink
// - it wasn't invalid
// - the symlink type (file/dir) was the same
// - the block list (i.e. hash of target) was the same
cf, ok = w.CurrentFiler.CurrentFile(rn)
if ok && !cf.IsDeleted() && cf.IsSymlink() && !cf.IsInvalid() && SymlinkTypeEqual(targetType, cf) && BlocksEqual(cf.Blocks, blocks) {
return skip
}
}
f := protocol.FileInfo{
Name: rn,
Version: cf.Version.Update(w.ShortID),
Flags: uint32(protocol.FlagSymlink | protocol.FlagNoPermBits | 0666 | SymlinkFlags(targetType)),
Modified: 0,
Blocks: blocks,
}
if debug {
l.Debugln("symlink changedb:", p, f)
}
dchan <- f
return skip
}
if info.Mode().IsDir() {
if w.CurrentFiler != nil {
// A directory is "unchanged", if it
// - exists
// - has the same permissions as previously, unless we are ignoring permissions
// - was not marked deleted (since it apparently exists now)
// - was a directory previously (not a file or something else)
// - was not a symlink (since it's a directory now)
// - was not invalid (since it looks valid now)
cf, ok = w.CurrentFiler.CurrentFile(rn)
permUnchanged := w.IgnorePerms || !cf.HasPermissionBits() || PermsEqual(cf.Flags, uint32(info.Mode()))