func ldbInsert(batch dbWriter, repo, node, name []byte, file protocol.FileInfo) { if debug { l.Debugf("insert; repo=%q node=%x %v", repo, node, file) } nk := nodeKey(repo, node, name) batch.Put(nk, file.MarshalXDR()) }
func ldbInsert(batch dbWriter, repo, node, name []byte, file protocol.FileInfo) uint64 { if debug { l.Debugf("insert; repo=%q node=%v %v", repo, protocol.NodeIDFromBytes(node), file) } if file.LocalVersion == 0 { file.LocalVersion = clock(0) } nk := nodeKey(repo, node, name) batch.Put(nk, file.MarshalXDR()) return file.LocalVersion }
func ldbReplaceWithDelete(db *leveldb.DB, repo, node []byte, fs []protocol.FileInfo) bool { return ldbGenericReplace(db, repo, node, fs, func(db dbReader, batch dbWriter, repo, node, name []byte, dbi iterator.Iterator) bool { var f protocol.FileInfo err := f.UnmarshalXDR(dbi.Value()) if err != nil { panic(err) } if !protocol.IsDeleted(f.Flags) { if debug { l.Debugf("mark deleted; repo=%q node=%x name=%q", repo, node, name) } f.Blocks = nil f.Version = lamport.Default.Tick(f.Version) f.Flags |= protocol.FlagDeleted batch.Put(dbi.Key(), f.MarshalXDR()) ldbUpdateGlobal(db, batch, repo, node, nodeKeyName(dbi.Key()), f.Version) return true } return false }) }