refactor: use modern Protobuf encoder (#9817)
At a high level, this is what I've done and why:
- I'm moving the protobuf generation for the `protocol`, `discovery` and
`db` packages to the modern alternatives, and using `buf` to generate
because it's nice and simple.
- After trying various approaches on how to integrate the new types with
the existing code, I opted for splitting off our own data model types
from the on-the-wire generated types. This means we can have a
`FileInfo` type with nicer ergonomics and lots of methods, while the
protobuf generated type stays clean and close to the wire protocol. It
does mean copying between the two when required, which certainly adds a
small amount of inefficiency. If we want to walk this back in the future
and use the raw generated type throughout, that's possible, this however
makes the refactor smaller (!) as it doesn't change everything about the
type for everyone at the same time.
- I have simply removed in cold blood a significant number of old
database migrations. These depended on previous generations of generated
messages of various kinds and were annoying to support in the new
fashion. The oldest supported database version now is the one from
Syncthing 1.9.0 from Sep 7, 2020.
- I changed config structs to be regular manually defined structs.
For the sake of discussion, some things I tried that turned out not to
work...
### Embedding / wrapping
Embedding the protobuf generated structs in our existing types as a data
container and keeping our methods and stuff:
```
package protocol
type FileInfo struct {
*generated.FileInfo
}
```
This generates a lot of problems because the internal shape of the
generated struct is quite different (different names, different types,
more pointers), because initializing it doesn't work like you'd expect
(i.e., you end up with an embedded nil pointer and a panic), and because
the types of child types don't get wrapped. That is, even if we also
have a similar wrapper around a `Vector`, that's not the type you get
when accessing `someFileInfo.Version`, you get the `*generated.Vector`
that doesn't have methods, etc.
### Aliasing
```
package protocol
type FileInfo = generated.FileInfo
```
Doesn't help because you can't attach methods to it, plus all the above.
### Generating the types into the target package like we do now and
attaching methods
This fails because of the different shape of the generated type (as in
the embedding case above) plus the generated struct already has a bunch
of methods that we can't necessarily override properly (like `String()`
and a bunch of getters).
### Methods to functions
I considered just moving all the methods we attach to functions in a
specific package, so that for example
```
package protocol
func (f FileInfo) Equal(other FileInfo) bool
```
would become
```
package fileinfos
func Equal(a, b *generated.FileInfo) bool
```
and this would mostly work, but becomes quite verbose and cumbersome,
and somewhat limits discoverability (you can't see what methods are
available on the type in auto completions, etc). In the end I did this
in some cases, like in the database layer where a lot of things like
`func (fv *FileVersion) IsEmpty() bool` becomes `func fvIsEmpty(fv
*generated.FileVersion)` because they were anyway just internal methods.
Fixes #8247
This commit is contained in:
@@ -90,7 +90,7 @@ func (f *fakeConnection) addFileLocked(name string, flags uint32, ftype protocol
|
||||
file.Permissions = flags
|
||||
if ftype == protocol.FileInfoTypeFile {
|
||||
file.Size = int64(len(data))
|
||||
file.RawBlockSize = blockSize
|
||||
file.RawBlockSize = int32(blockSize)
|
||||
file.Blocks = blocks
|
||||
}
|
||||
default: // Symlink
|
||||
|
||||
+35
-35
@@ -372,7 +372,7 @@ func (f *folder) pull() (success bool, err error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileInfo) bool {
|
||||
abort = false
|
||||
return false
|
||||
})
|
||||
@@ -702,7 +702,7 @@ func (f *folder) scanSubdirsChangedAndNew(subDirs []string, batch *scanBatch) (i
|
||||
}
|
||||
|
||||
func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *scanBatch) (int, error) {
|
||||
var toIgnore []db.FileInfoTruncated
|
||||
var toIgnore []protocol.FileInfo
|
||||
ignoredParent := ""
|
||||
changes := 0
|
||||
snap, err := f.dbSnapshot()
|
||||
@@ -714,24 +714,23 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *scanBatch
|
||||
for _, sub := range subDirs {
|
||||
var iterError error
|
||||
|
||||
snap.WithPrefixedHaveTruncated(protocol.LocalDeviceID, sub, func(fi protocol.FileIntf) bool {
|
||||
snap.WithPrefixedHaveTruncated(protocol.LocalDeviceID, sub, func(fi protocol.FileInfo) bool {
|
||||
select {
|
||||
case <-f.ctx.Done():
|
||||
return false
|
||||
default:
|
||||
}
|
||||
|
||||
file := fi.(db.FileInfoTruncated)
|
||||
|
||||
if err := batch.FlushIfFull(); err != nil {
|
||||
iterError = err
|
||||
return false
|
||||
}
|
||||
|
||||
if ignoredParent != "" && !fs.IsParent(file.Name, ignoredParent) {
|
||||
if ignoredParent != "" && !fs.IsParent(fi.Name, ignoredParent) {
|
||||
for _, file := range toIgnore {
|
||||
l.Debugln("marking file as ignored", file)
|
||||
nf := file.ConvertToIgnoredFileInfo()
|
||||
nf := file
|
||||
nf.SetIgnored()
|
||||
if batch.Update(nf, snap) {
|
||||
changes++
|
||||
}
|
||||
@@ -744,38 +743,39 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *scanBatch
|
||||
ignoredParent = ""
|
||||
}
|
||||
|
||||
switch ignored := f.ignores.Match(file.Name).IsIgnored(); {
|
||||
case file.IsIgnored() && ignored:
|
||||
switch ignored := f.ignores.Match(fi.Name).IsIgnored(); {
|
||||
case fi.IsIgnored() && ignored:
|
||||
return true
|
||||
case !file.IsIgnored() && ignored:
|
||||
case !fi.IsIgnored() && ignored:
|
||||
// File was not ignored at last pass but has been ignored.
|
||||
if file.IsDirectory() {
|
||||
if fi.IsDirectory() {
|
||||
// Delay ignoring as a child might be unignored.
|
||||
toIgnore = append(toIgnore, file)
|
||||
toIgnore = append(toIgnore, fi)
|
||||
if ignoredParent == "" {
|
||||
// If the parent wasn't ignored already, set
|
||||
// this path as the "highest" ignored parent
|
||||
ignoredParent = file.Name
|
||||
ignoredParent = fi.Name
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
l.Debugln("marking file as ignored", file)
|
||||
nf := file.ConvertToIgnoredFileInfo()
|
||||
l.Debugln("marking file as ignored", fi)
|
||||
nf := fi
|
||||
nf.SetIgnored()
|
||||
if batch.Update(nf, snap) {
|
||||
changes++
|
||||
}
|
||||
|
||||
case file.IsIgnored() && !ignored:
|
||||
case fi.IsIgnored() && !ignored:
|
||||
// Successfully scanned items are already un-ignored during
|
||||
// the scan, so check whether it is deleted.
|
||||
fallthrough
|
||||
case !file.IsIgnored() && !file.IsDeleted() && !file.IsUnsupported():
|
||||
case !fi.IsIgnored() && !fi.IsDeleted() && !fi.IsUnsupported():
|
||||
// The file is not ignored, deleted or unsupported. Lets check if
|
||||
// it's still here. Simply stat:ing it won't do as there are
|
||||
// tons of corner cases (e.g. parent dir->symlink, missing
|
||||
// permissions)
|
||||
if !osutil.IsDeleted(f.mtimefs, file.Name) {
|
||||
if !osutil.IsDeleted(f.mtimefs, fi.Name) {
|
||||
if ignoredParent != "" {
|
||||
// Don't ignore parents of this not ignored item
|
||||
toIgnore = toIgnore[:0]
|
||||
@@ -783,9 +783,10 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *scanBatch
|
||||
}
|
||||
return true
|
||||
}
|
||||
nf := file.ConvertToDeletedFileInfo(f.shortID)
|
||||
nf := fi
|
||||
nf.SetDeleted(f.shortID)
|
||||
nf.LocalFlags = f.localFlags
|
||||
if file.ShouldConflict() {
|
||||
if fi.ShouldConflict() {
|
||||
// We do not want to override the global version with
|
||||
// the deleted file. Setting to an empty version makes
|
||||
// sure the file gets in sync on the following pull.
|
||||
@@ -795,30 +796,30 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *scanBatch
|
||||
if batch.Update(nf, snap) {
|
||||
changes++
|
||||
}
|
||||
case file.IsDeleted() && file.IsReceiveOnlyChanged():
|
||||
case fi.IsDeleted() && fi.IsReceiveOnlyChanged():
|
||||
switch f.Type {
|
||||
case config.FolderTypeReceiveOnly, config.FolderTypeReceiveEncrypted:
|
||||
switch gf, ok := snap.GetGlobal(file.Name); {
|
||||
switch gf, ok := snap.GetGlobal(fi.Name); {
|
||||
case !ok:
|
||||
case gf.IsReceiveOnlyChanged():
|
||||
l.Debugln("removing deleted, receive-only item that is globally receive-only from db", file)
|
||||
batch.Remove(file.Name)
|
||||
l.Debugln("removing deleted, receive-only item that is globally receive-only from db", fi)
|
||||
batch.Remove(fi.Name)
|
||||
changes++
|
||||
case gf.IsDeleted():
|
||||
// Our item is deleted and the global item is deleted too. We just
|
||||
// pretend it is a normal deleted file (nobody cares about that).
|
||||
l.Debugf("%v scanning: Marking globally deleted item as not locally changed: %v", f, file.Name)
|
||||
file.LocalFlags &^= protocol.FlagLocalReceiveOnly
|
||||
if batch.Update(file.ConvertDeletedToFileInfo(), snap) {
|
||||
l.Debugf("%v scanning: Marking globally deleted item as not locally changed: %v", f, fi.Name)
|
||||
fi.LocalFlags &^= protocol.FlagLocalReceiveOnly
|
||||
if batch.Update(fi, snap) {
|
||||
changes++
|
||||
}
|
||||
}
|
||||
default:
|
||||
// No need to bump the version for a file that was and is
|
||||
// deleted and just the folder type/local flags changed.
|
||||
file.LocalFlags &^= protocol.FlagLocalReceiveOnly
|
||||
l.Debugln("removing receive-only flag on deleted item", file)
|
||||
if batch.Update(file.ConvertDeletedToFileInfo(), snap) {
|
||||
fi.LocalFlags &^= protocol.FlagLocalReceiveOnly
|
||||
l.Debugln("removing receive-only flag on deleted item", fi)
|
||||
if batch.Update(fi, snap) {
|
||||
changes++
|
||||
}
|
||||
}
|
||||
@@ -835,8 +836,9 @@ func (f *folder) scanSubdirsDeletedAndIgnored(subDirs []string, batch *scanBatch
|
||||
|
||||
if iterError == nil && len(toIgnore) > 0 {
|
||||
for _, file := range toIgnore {
|
||||
l.Debugln("marking file as ignored", f)
|
||||
nf := file.ConvertToIgnoredFileInfo()
|
||||
l.Debugln("marking file as ignored", file)
|
||||
nf := file
|
||||
nf.SetIgnored()
|
||||
if batch.Update(nf, snap) {
|
||||
changes++
|
||||
}
|
||||
@@ -863,9 +865,7 @@ func (f *folder) findRename(snap *db.Snapshot, file protocol.FileInfo, alreadyUs
|
||||
found := false
|
||||
nf := protocol.FileInfo{}
|
||||
|
||||
snap.WithBlocksHash(file.BlocksHash, func(ifi protocol.FileIntf) bool {
|
||||
fi := ifi.(protocol.FileInfo)
|
||||
|
||||
snap.WithBlocksHash(file.BlocksHash, func(fi protocol.FileInfo) bool {
|
||||
select {
|
||||
case <-f.ctx.Done():
|
||||
return false
|
||||
|
||||
@@ -56,26 +56,25 @@ func (f *receiveEncryptedFolder) revert() error {
|
||||
defer snap.Release()
|
||||
var iterErr error
|
||||
var dirs []string
|
||||
snap.WithHaveTruncated(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
||||
snap.WithHaveTruncated(protocol.LocalDeviceID, func(fi protocol.FileInfo) bool {
|
||||
if iterErr = batch.FlushIfFull(); iterErr != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
fit := intf.(db.FileInfoTruncated)
|
||||
if !fit.IsReceiveOnlyChanged() || intf.IsDeleted() {
|
||||
if !fi.IsReceiveOnlyChanged() || fi.IsDeleted() {
|
||||
return true
|
||||
}
|
||||
|
||||
if fit.IsDirectory() {
|
||||
dirs = append(dirs, fit.Name)
|
||||
if fi.IsDirectory() {
|
||||
dirs = append(dirs, fi.Name)
|
||||
return true
|
||||
}
|
||||
|
||||
if err := f.inWritableDir(f.mtimefs.Remove, fit.Name); err != nil && !fs.IsNotExist(err) {
|
||||
f.newScanError(fit.Name, fmt.Errorf("deleting unexpected item: %w", err))
|
||||
if err := f.inWritableDir(f.mtimefs.Remove, fi.Name); err != nil && !fs.IsNotExist(err) {
|
||||
f.newScanError(fi.Name, fmt.Errorf("deleting unexpected item: %w", err))
|
||||
}
|
||||
|
||||
fi := fit.ConvertToDeletedFileInfo(f.shortID)
|
||||
fi.SetDeleted(f.shortID)
|
||||
// Set version to zero, such that we pull the global version in case
|
||||
// this is a valid filename that was erroneously changed locally.
|
||||
// Should already be zero from scanning, but lets be safe.
|
||||
|
||||
@@ -92,8 +92,7 @@ func (f *receiveOnlyFolder) revert() error {
|
||||
return err
|
||||
}
|
||||
defer snap.Release()
|
||||
snap.WithHave(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
||||
fi := intf.(protocol.FileInfo)
|
||||
snap.WithHave(protocol.LocalDeviceID, func(fi protocol.FileInfo) bool {
|
||||
if !fi.IsReceiveOnlyChanged() {
|
||||
// We're only interested in files that have changed locally in
|
||||
// receive only mode.
|
||||
@@ -216,7 +215,7 @@ func (q *deleteQueue) flush(snap *db.Snapshot) ([]string, error) {
|
||||
for _, dir := range q.dirs {
|
||||
if err := q.handler.deleteDirOnDisk(dir, snap, q.scanChan); err == nil {
|
||||
deleted = append(deleted, dir)
|
||||
} else if err != nil && firstError == nil {
|
||||
} else if firstError == nil {
|
||||
firstError = err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,11 +391,10 @@ func TestRecvOnlyRemoteUndoChanges(t *testing.T) {
|
||||
|
||||
files := make([]protocol.FileInfo, 0, 2)
|
||||
snap := fsetSnapshot(t, f.fset)
|
||||
snap.WithHave(protocol.LocalDeviceID, func(fi protocol.FileIntf) bool {
|
||||
if n := fi.FileName(); n != file && n != knownFile {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(f protocol.FileInfo) bool {
|
||||
if f.Name != file && f.Name != knownFile {
|
||||
return true
|
||||
}
|
||||
f := fi.(protocol.FileInfo)
|
||||
f.LocalFlags = 0
|
||||
f.Version = protocol.Vector{}.Update(device1.Short())
|
||||
files = append(files, f)
|
||||
@@ -576,7 +575,7 @@ func setupKnownFiles(t *testing.T, ffs fs.Filesystem, data []byte) []protocol.Fi
|
||||
Permissions: 0o644,
|
||||
Size: fi.Size(),
|
||||
ModifiedS: fi.ModTime().Unix(),
|
||||
ModifiedNs: int(fi.ModTime().UnixNano() % 1e9),
|
||||
ModifiedNs: int32(fi.ModTime().Nanosecond()),
|
||||
Version: protocol.Vector{Counters: []protocol.Counter{{ID: 42, Value: 42}}},
|
||||
Sequence: 42,
|
||||
Blocks: blocks,
|
||||
|
||||
@@ -48,24 +48,22 @@ func (f *sendOnlyFolder) pull() (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
defer snap.Release()
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(file protocol.FileInfo) bool {
|
||||
batch.FlushIfFull()
|
||||
|
||||
file := intf.(protocol.FileInfo)
|
||||
|
||||
if f.ignores.Match(intf.FileName()).IsIgnored() {
|
||||
if f.ignores.Match(file.FileName()).IsIgnored() {
|
||||
file.SetIgnored()
|
||||
batch.Append(file)
|
||||
l.Debugln(f, "Handling ignored file", file)
|
||||
return true
|
||||
}
|
||||
|
||||
curFile, ok := snap.Get(protocol.LocalDeviceID, intf.FileName())
|
||||
curFile, ok := snap.Get(protocol.LocalDeviceID, file.FileName())
|
||||
if !ok {
|
||||
if intf.IsInvalid() {
|
||||
if file.IsInvalid() {
|
||||
// Global invalid file just exists for need accounting
|
||||
batch.Append(file)
|
||||
} else if intf.IsDeleted() {
|
||||
} else if file.IsDeleted() {
|
||||
l.Debugln("Should never get a deleted file as needed when we don't have it")
|
||||
f.evLogger.Log(events.Failure, "got deleted file that doesn't exist locally as needed when pulling on send-only")
|
||||
}
|
||||
@@ -111,8 +109,7 @@ func (f *sendOnlyFolder) override() error {
|
||||
return err
|
||||
}
|
||||
defer snap.Release()
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(fi protocol.FileIntf) bool {
|
||||
need := fi.(protocol.FileInfo)
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(need protocol.FileInfo) bool {
|
||||
_ = batch.FlushIfFull()
|
||||
|
||||
have, ok := snap.Get(protocol.LocalDeviceID, need.Name)
|
||||
|
||||
@@ -326,22 +326,20 @@ func (f *sendReceiveFolder) processNeeded(snap *db.Snapshot, dbUpdateChan chan<-
|
||||
// Regular files to pull goes into the file queue, everything else
|
||||
// (directories, symlinks and deletes) goes into the "process directly"
|
||||
// pile.
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
|
||||
snap.WithNeed(protocol.LocalDeviceID, func(file protocol.FileInfo) bool {
|
||||
select {
|
||||
case <-f.ctx.Done():
|
||||
return false
|
||||
default:
|
||||
}
|
||||
|
||||
if f.IgnoreDelete && intf.IsDeleted() {
|
||||
l.Debugln(f, "ignore file deletion (config)", intf.FileName())
|
||||
if f.IgnoreDelete && file.IsDeleted() {
|
||||
l.Debugln(f, "ignore file deletion (config)", file.FileName())
|
||||
return true
|
||||
}
|
||||
|
||||
changed++
|
||||
|
||||
file := intf.(protocol.FileInfo)
|
||||
|
||||
switch {
|
||||
case f.ignores.Match(file.Name).IsIgnored():
|
||||
file.SetIgnored()
|
||||
@@ -1021,13 +1019,13 @@ func (f *sendReceiveFolder) renameFile(cur, source, target protocol.FileInfo, sn
|
||||
if f.versioner != nil {
|
||||
err = f.CheckAvailableSpace(uint64(source.Size))
|
||||
if err == nil {
|
||||
err = osutil.Copy(f.CopyRangeMethod, f.mtimefs, f.mtimefs, source.Name, tempName)
|
||||
err = osutil.Copy(f.CopyRangeMethod.ToFS(), f.mtimefs, f.mtimefs, source.Name, tempName)
|
||||
if err == nil {
|
||||
err = f.inWritableDir(f.versioner.Archive, source.Name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = osutil.RenameOrCopy(f.CopyRangeMethod, f.mtimefs, f.mtimefs, source.Name, tempName)
|
||||
err = osutil.RenameOrCopy(f.CopyRangeMethod.ToFS(), f.mtimefs, f.mtimefs, source.Name, tempName)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1387,11 +1385,11 @@ func (f *sendReceiveFolder) copierRoutine(in <-chan copyBlocksState, pullChan ch
|
||||
}
|
||||
}
|
||||
|
||||
if f.CopyRangeMethod != fs.CopyRangeMethodStandard {
|
||||
if f.CopyRangeMethod != config.CopyRangeMethodStandard {
|
||||
err = f.withLimiter(func() error {
|
||||
dstFd.mut.Lock()
|
||||
defer dstFd.mut.Unlock()
|
||||
return fs.CopyRange(f.CopyRangeMethod, fd, dstFd.fd, srcOffset, block.Offset, int64(block.Size))
|
||||
return fs.CopyRange(f.CopyRangeMethod.ToFS(), fd, dstFd.fd, srcOffset, block.Offset, int64(block.Size))
|
||||
})
|
||||
} else {
|
||||
err = f.limitedWriteAt(dstFd, buf, block.Offset)
|
||||
@@ -1651,7 +1649,7 @@ func (f *sendReceiveFolder) performFinish(file, curFile protocol.FileInfo, hasCu
|
||||
|
||||
// Replace the original content with the new one. If it didn't work,
|
||||
// leave the temp file in place for reuse.
|
||||
if err := osutil.RenameOrCopy(f.CopyRangeMethod, f.mtimefs, f.mtimefs, tempName, file.Name); err != nil {
|
||||
if err := osutil.RenameOrCopy(f.CopyRangeMethod.ToFS(), f.mtimefs, f.mtimefs, tempName, file.Name); err != nil {
|
||||
return fmt.Errorf("replacing file: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ func TestWeakHash(t *testing.T) {
|
||||
Blocks: existing,
|
||||
Size: size,
|
||||
ModifiedS: info.ModTime().Unix(),
|
||||
ModifiedNs: info.ModTime().Nanosecond(),
|
||||
ModifiedNs: int32(info.ModTime().Nanosecond()),
|
||||
}
|
||||
desiredFile := protocol.FileInfo{
|
||||
Name: "weakhash",
|
||||
@@ -812,7 +812,7 @@ func TestCopyOwner(t *testing.T) {
|
||||
|
||||
m, f, wcfgCancel := setupSendReceiveFolder(t)
|
||||
defer wcfgCancel()
|
||||
f.folder.FolderConfiguration = newFolderConfiguration(m.cfg, f.ID, f.Label, fs.FilesystemTypeFake, "/TestCopyOwner")
|
||||
f.folder.FolderConfiguration = newFolderConfiguration(m.cfg, f.ID, f.Label, config.FilesystemTypeFake, "/TestCopyOwner")
|
||||
f.folder.FolderConfiguration.CopyOwnershipFromParent = true
|
||||
|
||||
f.fset = newFileSet(t, f.ID, m.db)
|
||||
@@ -1101,11 +1101,11 @@ func TestPullCaseOnlyPerformFinish(t *testing.T) {
|
||||
hasCur := false
|
||||
snap := dbSnapshot(t, m, f.ID)
|
||||
defer snap.Release()
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileIntf) bool {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileInfo) bool {
|
||||
if hasCur {
|
||||
t.Fatal("got more than one file")
|
||||
}
|
||||
cur = i.(protocol.FileInfo)
|
||||
cur = i
|
||||
hasCur = true
|
||||
return true
|
||||
})
|
||||
@@ -1166,11 +1166,11 @@ func testPullCaseOnlyDirOrSymlink(t *testing.T, dir bool) {
|
||||
hasCur := false
|
||||
snap := dbSnapshot(t, m, f.ID)
|
||||
defer snap.Release()
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileIntf) bool {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileInfo) bool {
|
||||
if hasCur {
|
||||
t.Fatal("got more than one file")
|
||||
}
|
||||
cur = i.(protocol.FileInfo)
|
||||
cur = i
|
||||
hasCur = true
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -292,7 +292,7 @@ func (s *indexHandler) sendIndexTo(ctx context.Context, fset *db.FileSet) error
|
||||
}
|
||||
defer snap.Release()
|
||||
previousWasDelete := false
|
||||
snap.WithHaveSequence(s.localPrevSequence+1, func(fi protocol.FileIntf) bool {
|
||||
snap.WithHaveSequence(s.localPrevSequence+1, func(fi protocol.FileInfo) bool {
|
||||
// This is to make sure that renames (which is an add followed by a delete) land in the same batch.
|
||||
// Even if the batch is full, we allow a last delete to slip in, we do this by making sure that
|
||||
// the batch ends with a non-delete, or that the last item in the batch is already a delete
|
||||
@@ -329,7 +329,7 @@ func (s *indexHandler) sendIndexTo(ctx context.Context, fset *db.FileSet) error
|
||||
return false
|
||||
}
|
||||
|
||||
f = fi.(protocol.FileInfo)
|
||||
f = fi
|
||||
|
||||
// If this is a folder receiving encrypted files only, we
|
||||
// mustn't ever send locally changed file infos. Those aren't
|
||||
|
||||
@@ -9,10 +9,6 @@ import (
|
||||
)
|
||||
|
||||
type FolderSummaryService struct {
|
||||
OnEventRequestStub func()
|
||||
onEventRequestMutex sync.RWMutex
|
||||
onEventRequestArgsForCall []struct {
|
||||
}
|
||||
ServeStub func(context.Context) error
|
||||
serveMutex sync.RWMutex
|
||||
serveArgsForCall []struct {
|
||||
@@ -41,30 +37,6 @@ type FolderSummaryService struct {
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (fake *FolderSummaryService) OnEventRequest() {
|
||||
fake.onEventRequestMutex.Lock()
|
||||
fake.onEventRequestArgsForCall = append(fake.onEventRequestArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.OnEventRequestStub
|
||||
fake.recordInvocation("OnEventRequest", []interface{}{})
|
||||
fake.onEventRequestMutex.Unlock()
|
||||
if stub != nil {
|
||||
fake.OnEventRequestStub()
|
||||
}
|
||||
}
|
||||
|
||||
func (fake *FolderSummaryService) OnEventRequestCallCount() int {
|
||||
fake.onEventRequestMutex.RLock()
|
||||
defer fake.onEventRequestMutex.RUnlock()
|
||||
return len(fake.onEventRequestArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FolderSummaryService) OnEventRequestCalls(stub func()) {
|
||||
fake.onEventRequestMutex.Lock()
|
||||
defer fake.onEventRequestMutex.Unlock()
|
||||
fake.OnEventRequestStub = stub
|
||||
}
|
||||
|
||||
func (fake *FolderSummaryService) Serve(arg1 context.Context) error {
|
||||
fake.serveMutex.Lock()
|
||||
ret, specificReturn := fake.serveReturnsOnCall[len(fake.serveArgsForCall)]
|
||||
@@ -193,8 +165,6 @@ func (fake *FolderSummaryService) SummaryReturnsOnCall(i int, result1 *model.Fol
|
||||
func (fake *FolderSummaryService) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.onEventRequestMutex.RLock()
|
||||
defer fake.onEventRequestMutex.RUnlock()
|
||||
fake.serveMutex.RLock()
|
||||
defer fake.serveMutex.RUnlock()
|
||||
fake.summaryMutex.RLock()
|
||||
|
||||
+40
-40
@@ -328,7 +328,7 @@ type Model struct {
|
||||
result2 []string
|
||||
result3 error
|
||||
}
|
||||
LocalChangedFolderFilesStub func(string, int, int) ([]db.FileInfoTruncated, error)
|
||||
LocalChangedFolderFilesStub func(string, int, int) ([]protocol.FileInfo, error)
|
||||
localChangedFolderFilesMutex sync.RWMutex
|
||||
localChangedFolderFilesArgsForCall []struct {
|
||||
arg1 string
|
||||
@@ -336,14 +336,14 @@ type Model struct {
|
||||
arg3 int
|
||||
}
|
||||
localChangedFolderFilesReturns struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}
|
||||
localChangedFolderFilesReturnsOnCall map[int]struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}
|
||||
NeedFolderFilesStub func(string, int, int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error)
|
||||
NeedFolderFilesStub func(string, int, int) ([]protocol.FileInfo, []protocol.FileInfo, []protocol.FileInfo, error)
|
||||
needFolderFilesMutex sync.RWMutex
|
||||
needFolderFilesArgsForCall []struct {
|
||||
arg1 string
|
||||
@@ -351,15 +351,15 @@ type Model struct {
|
||||
arg3 int
|
||||
}
|
||||
needFolderFilesReturns struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result2 []db.FileInfoTruncated
|
||||
result3 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 []protocol.FileInfo
|
||||
result3 []protocol.FileInfo
|
||||
result4 error
|
||||
}
|
||||
needFolderFilesReturnsOnCall map[int]struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result2 []db.FileInfoTruncated
|
||||
result3 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 []protocol.FileInfo
|
||||
result3 []protocol.FileInfo
|
||||
result4 error
|
||||
}
|
||||
OnHelloStub func(protocol.DeviceID, net.Addr, protocol.Hello) error
|
||||
@@ -405,7 +405,7 @@ type Model struct {
|
||||
result1 map[string]db.PendingFolder
|
||||
result2 error
|
||||
}
|
||||
RemoteNeedFolderFilesStub func(string, protocol.DeviceID, int, int) ([]db.FileInfoTruncated, error)
|
||||
RemoteNeedFolderFilesStub func(string, protocol.DeviceID, int, int) ([]protocol.FileInfo, error)
|
||||
remoteNeedFolderFilesMutex sync.RWMutex
|
||||
remoteNeedFolderFilesArgsForCall []struct {
|
||||
arg1 string
|
||||
@@ -414,11 +414,11 @@ type Model struct {
|
||||
arg4 int
|
||||
}
|
||||
remoteNeedFolderFilesReturns struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}
|
||||
remoteNeedFolderFilesReturnsOnCall map[int]struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}
|
||||
RequestStub func(protocol.Connection, *protocol.Request) (protocol.RequestResponse, error)
|
||||
@@ -2095,7 +2095,7 @@ func (fake *Model) LoadIgnoresReturnsOnCall(i int, result1 []string, result2 []s
|
||||
}{result1, result2, result3}
|
||||
}
|
||||
|
||||
func (fake *Model) LocalChangedFolderFiles(arg1 string, arg2 int, arg3 int) ([]db.FileInfoTruncated, error) {
|
||||
func (fake *Model) LocalChangedFolderFiles(arg1 string, arg2 int, arg3 int) ([]protocol.FileInfo, error) {
|
||||
fake.localChangedFolderFilesMutex.Lock()
|
||||
ret, specificReturn := fake.localChangedFolderFilesReturnsOnCall[len(fake.localChangedFolderFilesArgsForCall)]
|
||||
fake.localChangedFolderFilesArgsForCall = append(fake.localChangedFolderFilesArgsForCall, struct {
|
||||
@@ -2122,7 +2122,7 @@ func (fake *Model) LocalChangedFolderFilesCallCount() int {
|
||||
return len(fake.localChangedFolderFilesArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Model) LocalChangedFolderFilesCalls(stub func(string, int, int) ([]db.FileInfoTruncated, error)) {
|
||||
func (fake *Model) LocalChangedFolderFilesCalls(stub func(string, int, int) ([]protocol.FileInfo, error)) {
|
||||
fake.localChangedFolderFilesMutex.Lock()
|
||||
defer fake.localChangedFolderFilesMutex.Unlock()
|
||||
fake.LocalChangedFolderFilesStub = stub
|
||||
@@ -2135,33 +2135,33 @@ func (fake *Model) LocalChangedFolderFilesArgsForCall(i int) (string, int, int)
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
}
|
||||
|
||||
func (fake *Model) LocalChangedFolderFilesReturns(result1 []db.FileInfoTruncated, result2 error) {
|
||||
func (fake *Model) LocalChangedFolderFilesReturns(result1 []protocol.FileInfo, result2 error) {
|
||||
fake.localChangedFolderFilesMutex.Lock()
|
||||
defer fake.localChangedFolderFilesMutex.Unlock()
|
||||
fake.LocalChangedFolderFilesStub = nil
|
||||
fake.localChangedFolderFilesReturns = struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *Model) LocalChangedFolderFilesReturnsOnCall(i int, result1 []db.FileInfoTruncated, result2 error) {
|
||||
func (fake *Model) LocalChangedFolderFilesReturnsOnCall(i int, result1 []protocol.FileInfo, result2 error) {
|
||||
fake.localChangedFolderFilesMutex.Lock()
|
||||
defer fake.localChangedFolderFilesMutex.Unlock()
|
||||
fake.LocalChangedFolderFilesStub = nil
|
||||
if fake.localChangedFolderFilesReturnsOnCall == nil {
|
||||
fake.localChangedFolderFilesReturnsOnCall = make(map[int]struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.localChangedFolderFilesReturnsOnCall[i] = struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *Model) NeedFolderFiles(arg1 string, arg2 int, arg3 int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error) {
|
||||
func (fake *Model) NeedFolderFiles(arg1 string, arg2 int, arg3 int) ([]protocol.FileInfo, []protocol.FileInfo, []protocol.FileInfo, error) {
|
||||
fake.needFolderFilesMutex.Lock()
|
||||
ret, specificReturn := fake.needFolderFilesReturnsOnCall[len(fake.needFolderFilesArgsForCall)]
|
||||
fake.needFolderFilesArgsForCall = append(fake.needFolderFilesArgsForCall, struct {
|
||||
@@ -2188,7 +2188,7 @@ func (fake *Model) NeedFolderFilesCallCount() int {
|
||||
return len(fake.needFolderFilesArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Model) NeedFolderFilesCalls(stub func(string, int, int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error)) {
|
||||
func (fake *Model) NeedFolderFilesCalls(stub func(string, int, int) ([]protocol.FileInfo, []protocol.FileInfo, []protocol.FileInfo, error)) {
|
||||
fake.needFolderFilesMutex.Lock()
|
||||
defer fake.needFolderFilesMutex.Unlock()
|
||||
fake.NeedFolderFilesStub = stub
|
||||
@@ -2201,34 +2201,34 @@ func (fake *Model) NeedFolderFilesArgsForCall(i int) (string, int, int) {
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
}
|
||||
|
||||
func (fake *Model) NeedFolderFilesReturns(result1 []db.FileInfoTruncated, result2 []db.FileInfoTruncated, result3 []db.FileInfoTruncated, result4 error) {
|
||||
func (fake *Model) NeedFolderFilesReturns(result1 []protocol.FileInfo, result2 []protocol.FileInfo, result3 []protocol.FileInfo, result4 error) {
|
||||
fake.needFolderFilesMutex.Lock()
|
||||
defer fake.needFolderFilesMutex.Unlock()
|
||||
fake.NeedFolderFilesStub = nil
|
||||
fake.needFolderFilesReturns = struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result2 []db.FileInfoTruncated
|
||||
result3 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 []protocol.FileInfo
|
||||
result3 []protocol.FileInfo
|
||||
result4 error
|
||||
}{result1, result2, result3, result4}
|
||||
}
|
||||
|
||||
func (fake *Model) NeedFolderFilesReturnsOnCall(i int, result1 []db.FileInfoTruncated, result2 []db.FileInfoTruncated, result3 []db.FileInfoTruncated, result4 error) {
|
||||
func (fake *Model) NeedFolderFilesReturnsOnCall(i int, result1 []protocol.FileInfo, result2 []protocol.FileInfo, result3 []protocol.FileInfo, result4 error) {
|
||||
fake.needFolderFilesMutex.Lock()
|
||||
defer fake.needFolderFilesMutex.Unlock()
|
||||
fake.NeedFolderFilesStub = nil
|
||||
if fake.needFolderFilesReturnsOnCall == nil {
|
||||
fake.needFolderFilesReturnsOnCall = make(map[int]struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result2 []db.FileInfoTruncated
|
||||
result3 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 []protocol.FileInfo
|
||||
result3 []protocol.FileInfo
|
||||
result4 error
|
||||
})
|
||||
}
|
||||
fake.needFolderFilesReturnsOnCall[i] = struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result2 []db.FileInfoTruncated
|
||||
result3 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 []protocol.FileInfo
|
||||
result3 []protocol.FileInfo
|
||||
result4 error
|
||||
}{result1, result2, result3, result4}
|
||||
}
|
||||
@@ -2448,7 +2448,7 @@ func (fake *Model) PendingFoldersReturnsOnCall(i int, result1 map[string]db.Pend
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *Model) RemoteNeedFolderFiles(arg1 string, arg2 protocol.DeviceID, arg3 int, arg4 int) ([]db.FileInfoTruncated, error) {
|
||||
func (fake *Model) RemoteNeedFolderFiles(arg1 string, arg2 protocol.DeviceID, arg3 int, arg4 int) ([]protocol.FileInfo, error) {
|
||||
fake.remoteNeedFolderFilesMutex.Lock()
|
||||
ret, specificReturn := fake.remoteNeedFolderFilesReturnsOnCall[len(fake.remoteNeedFolderFilesArgsForCall)]
|
||||
fake.remoteNeedFolderFilesArgsForCall = append(fake.remoteNeedFolderFilesArgsForCall, struct {
|
||||
@@ -2476,7 +2476,7 @@ func (fake *Model) RemoteNeedFolderFilesCallCount() int {
|
||||
return len(fake.remoteNeedFolderFilesArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Model) RemoteNeedFolderFilesCalls(stub func(string, protocol.DeviceID, int, int) ([]db.FileInfoTruncated, error)) {
|
||||
func (fake *Model) RemoteNeedFolderFilesCalls(stub func(string, protocol.DeviceID, int, int) ([]protocol.FileInfo, error)) {
|
||||
fake.remoteNeedFolderFilesMutex.Lock()
|
||||
defer fake.remoteNeedFolderFilesMutex.Unlock()
|
||||
fake.RemoteNeedFolderFilesStub = stub
|
||||
@@ -2489,28 +2489,28 @@ func (fake *Model) RemoteNeedFolderFilesArgsForCall(i int) (string, protocol.Dev
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
|
||||
}
|
||||
|
||||
func (fake *Model) RemoteNeedFolderFilesReturns(result1 []db.FileInfoTruncated, result2 error) {
|
||||
func (fake *Model) RemoteNeedFolderFilesReturns(result1 []protocol.FileInfo, result2 error) {
|
||||
fake.remoteNeedFolderFilesMutex.Lock()
|
||||
defer fake.remoteNeedFolderFilesMutex.Unlock()
|
||||
fake.RemoteNeedFolderFilesStub = nil
|
||||
fake.remoteNeedFolderFilesReturns = struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *Model) RemoteNeedFolderFilesReturnsOnCall(i int, result1 []db.FileInfoTruncated, result2 error) {
|
||||
func (fake *Model) RemoteNeedFolderFilesReturnsOnCall(i int, result1 []protocol.FileInfo, result2 error) {
|
||||
fake.remoteNeedFolderFilesMutex.Lock()
|
||||
defer fake.remoteNeedFolderFilesMutex.Unlock()
|
||||
fake.RemoteNeedFolderFilesStub = nil
|
||||
if fake.remoteNeedFolderFilesReturnsOnCall == nil {
|
||||
fake.remoteNeedFolderFilesReturnsOnCall = make(map[int]struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.remoteNeedFolderFilesReturnsOnCall[i] = struct {
|
||||
result1 []db.FileInfoTruncated
|
||||
result1 []protocol.FileInfo
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
+24
-28
@@ -94,9 +94,9 @@ type Model interface {
|
||||
RestoreFolderVersions(folder string, versions map[string]time.Time) (map[string]error, error)
|
||||
|
||||
DBSnapshot(folder string) (*db.Snapshot, error)
|
||||
NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error)
|
||||
RemoteNeedFolderFiles(folder string, device protocol.DeviceID, page, perpage int) ([]db.FileInfoTruncated, error)
|
||||
LocalChangedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, error)
|
||||
NeedFolderFiles(folder string, page, perpage int) ([]protocol.FileInfo, []protocol.FileInfo, []protocol.FileInfo, error)
|
||||
RemoteNeedFolderFiles(folder string, device protocol.DeviceID, page, perpage int) ([]protocol.FileInfo, error)
|
||||
LocalChangedFolderFiles(folder string, page, perpage int) ([]protocol.FileInfo, error)
|
||||
FolderProgressBytesCompleted(folder string) int64
|
||||
|
||||
CurrentFolderFile(folder string, file string) (protocol.FileInfo, bool, error)
|
||||
@@ -944,7 +944,7 @@ func (m *model) folderCompletion(device protocol.DeviceID, folder string) (Folde
|
||||
|
||||
need := snap.NeedSize(device)
|
||||
need.Bytes -= downloaded
|
||||
// This might might be more than it really is, because some blocks can be of a smaller size.
|
||||
// This might be more than it really is, because some blocks can be of a smaller size.
|
||||
if need.Bytes < 0 {
|
||||
need.Bytes = 0
|
||||
}
|
||||
@@ -973,7 +973,7 @@ func (m *model) FolderProgressBytesCompleted(folder string) int64 {
|
||||
|
||||
// NeedFolderFiles returns paginated list of currently needed files in
|
||||
// progress, queued, and to be queued on next puller iteration.
|
||||
func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, []db.FileInfoTruncated, []db.FileInfoTruncated, error) {
|
||||
func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]protocol.FileInfo, []protocol.FileInfo, []protocol.FileInfo, error) {
|
||||
m.mut.RLock()
|
||||
rf, rfOk := m.folderFiles[folder]
|
||||
runner, runnerOk := m.folderRunners.Get(folder)
|
||||
@@ -989,7 +989,7 @@ func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfo
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
defer snap.Release()
|
||||
var progress, queued, rest []db.FileInfoTruncated
|
||||
var progress, queued, rest []protocol.FileInfo
|
||||
var seen map[string]struct{}
|
||||
|
||||
p := newPager(page, perpage)
|
||||
@@ -997,8 +997,8 @@ func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfo
|
||||
if runnerOk {
|
||||
progressNames, queuedNames, skipped := runner.Jobs(page, perpage)
|
||||
|
||||
progress = make([]db.FileInfoTruncated, len(progressNames))
|
||||
queued = make([]db.FileInfoTruncated, len(queuedNames))
|
||||
progress = make([]protocol.FileInfo, len(progressNames))
|
||||
queued = make([]protocol.FileInfo, len(queuedNames))
|
||||
seen = make(map[string]struct{}, len(progressNames)+len(queuedNames))
|
||||
|
||||
for i, name := range progressNames {
|
||||
@@ -1022,8 +1022,8 @@ func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfo
|
||||
p.toSkip -= skipped
|
||||
}
|
||||
|
||||
rest = make([]db.FileInfoTruncated, 0, perpage)
|
||||
snap.WithNeedTruncated(protocol.LocalDeviceID, func(f protocol.FileIntf) bool {
|
||||
rest = make([]protocol.FileInfo, 0, perpage)
|
||||
snap.WithNeedTruncated(protocol.LocalDeviceID, func(f protocol.FileInfo) bool {
|
||||
if cfg.IgnoreDelete && f.IsDeleted() {
|
||||
return true
|
||||
}
|
||||
@@ -1031,9 +1031,8 @@ func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfo
|
||||
if p.skip() {
|
||||
return true
|
||||
}
|
||||
ft := f.(db.FileInfoTruncated)
|
||||
if _, ok := seen[ft.Name]; !ok {
|
||||
rest = append(rest, ft)
|
||||
if _, ok := seen[f.Name]; !ok {
|
||||
rest = append(rest, f)
|
||||
p.get--
|
||||
}
|
||||
return p.get > 0
|
||||
@@ -1044,7 +1043,7 @@ func (m *model) NeedFolderFiles(folder string, page, perpage int) ([]db.FileInfo
|
||||
|
||||
// RemoteNeedFolderFiles returns paginated list of currently needed files for a
|
||||
// remote device to become synced with a folder.
|
||||
func (m *model) RemoteNeedFolderFiles(folder string, device protocol.DeviceID, page, perpage int) ([]db.FileInfoTruncated, error) {
|
||||
func (m *model) RemoteNeedFolderFiles(folder string, device protocol.DeviceID, page, perpage int) ([]protocol.FileInfo, error) {
|
||||
m.mut.RLock()
|
||||
rf, ok := m.folderFiles[folder]
|
||||
m.mut.RUnlock()
|
||||
@@ -1059,19 +1058,19 @@ func (m *model) RemoteNeedFolderFiles(folder string, device protocol.DeviceID, p
|
||||
}
|
||||
defer snap.Release()
|
||||
|
||||
files := make([]db.FileInfoTruncated, 0, perpage)
|
||||
files := make([]protocol.FileInfo, 0, perpage)
|
||||
p := newPager(page, perpage)
|
||||
snap.WithNeedTruncated(device, func(f protocol.FileIntf) bool {
|
||||
snap.WithNeedTruncated(device, func(f protocol.FileInfo) bool {
|
||||
if p.skip() {
|
||||
return true
|
||||
}
|
||||
files = append(files, f.(db.FileInfoTruncated))
|
||||
files = append(files, f)
|
||||
return !p.done()
|
||||
})
|
||||
return files, nil
|
||||
}
|
||||
|
||||
func (m *model) LocalChangedFolderFiles(folder string, page, perpage int) ([]db.FileInfoTruncated, error) {
|
||||
func (m *model) LocalChangedFolderFiles(folder string, page, perpage int) ([]protocol.FileInfo, error) {
|
||||
m.mut.RLock()
|
||||
rf, ok := m.folderFiles[folder]
|
||||
m.mut.RUnlock()
|
||||
@@ -1091,17 +1090,16 @@ func (m *model) LocalChangedFolderFiles(folder string, page, perpage int) ([]db.
|
||||
}
|
||||
|
||||
p := newPager(page, perpage)
|
||||
files := make([]db.FileInfoTruncated, 0, perpage)
|
||||
files := make([]protocol.FileInfo, 0, perpage)
|
||||
|
||||
snap.WithHaveTruncated(protocol.LocalDeviceID, func(f protocol.FileIntf) bool {
|
||||
snap.WithHaveTruncated(protocol.LocalDeviceID, func(f protocol.FileInfo) bool {
|
||||
if !f.IsReceiveOnlyChanged() {
|
||||
return true
|
||||
}
|
||||
if p.skip() {
|
||||
return true
|
||||
}
|
||||
ft := f.(db.FileInfoTruncated)
|
||||
files = append(files, ft)
|
||||
files = append(files, f)
|
||||
return !p.done()
|
||||
})
|
||||
|
||||
@@ -1751,7 +1749,7 @@ func (*model) handleDeintroductions(introducerCfg config.DeviceConfiguration, fo
|
||||
// AutoAcceptFolders set to true.
|
||||
func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Folder, ccDeviceInfos *clusterConfigDeviceInfo, cfg config.FolderConfiguration, haveCfg bool, defaultFolderCfg config.FolderConfiguration) (config.FolderConfiguration, bool) {
|
||||
if !haveCfg {
|
||||
defaultPathFs := fs.NewFilesystem(defaultFolderCfg.FilesystemType, defaultFolderCfg.Path)
|
||||
defaultPathFs := fs.NewFilesystem(defaultFolderCfg.FilesystemType.ToFS(), defaultFolderCfg.Path)
|
||||
var pathAlternatives []string
|
||||
if alt := fs.SanitizePath(folder.Label); alt != "" {
|
||||
pathAlternatives = append(pathAlternatives, alt)
|
||||
@@ -2634,7 +2632,7 @@ func (m *model) generateClusterConfigRLocked(device protocol.DeviceID) (*protoco
|
||||
ID: deviceCfg.DeviceID,
|
||||
Name: deviceCfg.Name,
|
||||
Addresses: deviceCfg.Addresses,
|
||||
Compression: deviceCfg.Compression,
|
||||
Compression: deviceCfg.Compression.ToProtocol(),
|
||||
CertName: deviceCfg.CertName,
|
||||
Introducer: deviceCfg.Introducer,
|
||||
}
|
||||
@@ -2773,9 +2771,7 @@ func (m *model) GlobalDirectoryTree(folder, prefix string, levels int, dirsOnly
|
||||
return nil, err
|
||||
}
|
||||
defer snap.Release()
|
||||
snap.WithPrefixedGlobalTruncated(prefix, func(fi protocol.FileIntf) bool {
|
||||
f := fi.(db.FileInfoTruncated)
|
||||
|
||||
snap.WithPrefixedGlobalTruncated(prefix, func(f protocol.FileInfo) bool {
|
||||
// Don't include the prefix itself.
|
||||
if f.IsInvalid() || f.IsDeleted() || strings.HasPrefix(prefix, f.Name) {
|
||||
return true
|
||||
@@ -3471,7 +3467,7 @@ func writeEncryptionToken(token []byte, cfg config.FolderConfiguration) error {
|
||||
})
|
||||
}
|
||||
|
||||
func newFolderConfiguration(w config.Wrapper, id, label string, fsType fs.FilesystemType, path string) config.FolderConfiguration {
|
||||
func newFolderConfiguration(w config.Wrapper, id, label string, fsType config.FilesystemType, path string) config.FolderConfiguration {
|
||||
fcfg := w.DefaultFolder()
|
||||
fcfg.ID = id
|
||||
fcfg.Label = label
|
||||
|
||||
+42
-42
@@ -391,7 +391,7 @@ func TestClusterConfig(t *testing.T) {
|
||||
}
|
||||
cfg.Folders = []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata1",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -400,7 +400,7 @@ func TestClusterConfig(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata2",
|
||||
Paused: true, // should still be included
|
||||
@@ -410,7 +410,7 @@ func TestClusterConfig(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder3",
|
||||
Path: "testdata3",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -499,7 +499,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -507,7 +507,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -560,7 +560,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -569,7 +569,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -615,7 +615,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -624,7 +624,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -667,7 +667,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -676,7 +676,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -719,7 +719,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -728,7 +728,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -775,7 +775,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -784,7 +784,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -826,7 +826,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -835,7 +835,7 @@ func TestIntroducer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder2",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -873,7 +873,7 @@ func TestIssue4897(t *testing.T) {
|
||||
},
|
||||
Folders: []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: "testdata",
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -1030,7 +1030,7 @@ func TestAutoAcceptNewFolderPremutationsNoPanic(t *testing.T) {
|
||||
for _, dev2folder := range premutations {
|
||||
cfg := defaultAutoAcceptCfg.Copy()
|
||||
if localFolder.Label != "" {
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, localFolder.ID, localFolder.Label, fs.FilesystemTypeFake, localFolder.ID)
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, localFolder.ID, localFolder.Label, config.FilesystemTypeFake, localFolder.ID)
|
||||
fcfg.Paused = localFolderPaused
|
||||
cfg.Folders = append(cfg.Folders, fcfg)
|
||||
}
|
||||
@@ -1075,7 +1075,7 @@ func TestAutoAcceptExistingFolder(t *testing.T) {
|
||||
tcfg := defaultAutoAcceptCfg.Copy()
|
||||
tcfg.Folders = []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: id,
|
||||
Path: idOther, // To check that path does not get changed.
|
||||
},
|
||||
@@ -1101,7 +1101,7 @@ func TestAutoAcceptNewAndExistingFolder(t *testing.T) {
|
||||
tcfg := defaultAutoAcceptCfg.Copy()
|
||||
tcfg.Folders = []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: id1,
|
||||
Path: id1, // from previous test case, to verify that path doesn't get changed.
|
||||
},
|
||||
@@ -1127,7 +1127,7 @@ func TestAutoAcceptAlreadyShared(t *testing.T) {
|
||||
tcfg := defaultAutoAcceptCfg.Copy()
|
||||
tcfg.Folders = []config.FolderConfiguration{
|
||||
{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: id,
|
||||
Path: id,
|
||||
Devices: []config.FolderDeviceConfiguration{
|
||||
@@ -1226,7 +1226,7 @@ func TestAutoAcceptPausedWhenFolderConfigChanged(t *testing.T) {
|
||||
idOther := srand.String(8) // To check that path does not get changed.
|
||||
|
||||
tcfg := defaultAutoAcceptCfg.Copy()
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, id, "", fs.FilesystemTypeFake, idOther)
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, id, "", config.FilesystemTypeFake, idOther)
|
||||
fcfg.Paused = true
|
||||
// The order of devices here is wrong (cfg.clean() sorts them), which will cause the folder to restart.
|
||||
// Because of the restart, folder gets removed from m.deviceFolder, which means that generateClusterConfig will not panic.
|
||||
@@ -1272,7 +1272,7 @@ func TestAutoAcceptPausedWhenFolderConfigNotChanged(t *testing.T) {
|
||||
idOther := srand.String(8) // To check that path does not get changed.
|
||||
|
||||
tcfg := defaultAutoAcceptCfg.Copy()
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, id, "", fs.FilesystemTypeFake, idOther)
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, id, "", config.FilesystemTypeFake, idOther)
|
||||
fcfg.Paused = true
|
||||
// The new folder is exactly the same as the one constructed by handleAutoAccept, which means
|
||||
// the folder will not be restarted (even if it's paused), yet handleAutoAccept used to add the folder
|
||||
@@ -1521,7 +1521,7 @@ func TestIgnores(t *testing.T) {
|
||||
// Invalid path, treated like no patterns at all.
|
||||
fcfg := config.FolderConfiguration{
|
||||
ID: "fresh", Path: "XXX",
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
}
|
||||
ignores := ignore.New(fcfg.Filesystem(nil), ignore.WithCache(m.cfg.Options().CacheIgnoredFiles))
|
||||
m.mut.Lock()
|
||||
@@ -1609,7 +1609,7 @@ func waitForState(t *testing.T, sub events.Subscription, folder, expected string
|
||||
|
||||
func TestROScanRecovery(t *testing.T) {
|
||||
fcfg := config.FolderConfiguration{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "default",
|
||||
Path: srand.String(32),
|
||||
Type: config.FolderTypeSendOnly,
|
||||
@@ -1656,7 +1656,7 @@ func TestROScanRecovery(t *testing.T) {
|
||||
|
||||
func TestRWScanRecovery(t *testing.T) {
|
||||
fcfg := config.FolderConfiguration{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "default",
|
||||
Path: srand.String(32),
|
||||
Type: config.FolderTypeSendReceive,
|
||||
@@ -2522,7 +2522,7 @@ func TestVersionRestore(t *testing.T) {
|
||||
// We verify that the content matches at the expected filenames
|
||||
// after the restore operation.
|
||||
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, "default", "default", fs.FilesystemTypeFake, srand.String(32))
|
||||
fcfg := newFolderConfiguration(defaultCfgWrapper, "default", "default", config.FilesystemTypeFake, srand.String(32))
|
||||
fcfg.Versioning.Type = "simple"
|
||||
fcfg.FSWatcherEnabled = false
|
||||
filesystem := fcfg.Filesystem(nil)
|
||||
@@ -2744,7 +2744,7 @@ func TestIssue4094(t *testing.T) {
|
||||
folderPath := "nonexistent"
|
||||
cfg := defaultCfgWrapper.RawCopy()
|
||||
fcfg := config.FolderConfiguration{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
ID: "folder1",
|
||||
Path: folderPath,
|
||||
Paused: true,
|
||||
@@ -2861,7 +2861,7 @@ func TestFolderRestartZombies(t *testing.T) {
|
||||
waiter, err := wrapper.Modify(func(cfg *config.Configuration) {
|
||||
cfg.Options.RawMaxFolderConcurrency = -1
|
||||
_, i, _ := cfg.Folder("default")
|
||||
cfg.Folders[i].FilesystemType = fs.FilesystemTypeFake
|
||||
cfg.Folders[i].FilesystemType = config.FilesystemTypeFake
|
||||
})
|
||||
must(t, err)
|
||||
waiter.Wait()
|
||||
@@ -3204,7 +3204,7 @@ func TestRenameSequenceOrder(t *testing.T) {
|
||||
|
||||
count := 0
|
||||
snap := dbSnapshot(t, m, "default")
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileIntf) bool {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileInfo) bool {
|
||||
count++
|
||||
return true
|
||||
})
|
||||
@@ -3236,7 +3236,7 @@ func TestRenameSequenceOrder(t *testing.T) {
|
||||
var firstExpectedSequence int64
|
||||
var secondExpectedSequence int64
|
||||
failed := false
|
||||
snap.WithHaveSequence(0, func(i protocol.FileIntf) bool {
|
||||
snap.WithHaveSequence(0, func(i protocol.FileInfo) bool {
|
||||
t.Log(i)
|
||||
if i.FileName() == "17" {
|
||||
firstExpectedSequence = i.SequenceNo() + 1
|
||||
@@ -3270,7 +3270,7 @@ func TestRenameSameFile(t *testing.T) {
|
||||
|
||||
count := 0
|
||||
snap := dbSnapshot(t, m, "default")
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileIntf) bool {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileInfo) bool {
|
||||
count++
|
||||
return true
|
||||
})
|
||||
@@ -3293,7 +3293,7 @@ func TestRenameSameFile(t *testing.T) {
|
||||
|
||||
prevSeq := int64(0)
|
||||
seen := false
|
||||
snap.WithHaveSequence(0, func(i protocol.FileIntf) bool {
|
||||
snap.WithHaveSequence(0, func(i protocol.FileInfo) bool {
|
||||
if i.SequenceNo() <= prevSeq {
|
||||
t.Fatalf("non-increasing sequences: %d <= %d", i.SequenceNo(), prevSeq)
|
||||
}
|
||||
@@ -3333,7 +3333,7 @@ func TestRenameEmptyFile(t *testing.T) {
|
||||
}
|
||||
|
||||
count := 0
|
||||
snap.WithBlocksHash(empty.BlocksHash, func(_ protocol.FileIntf) bool {
|
||||
snap.WithBlocksHash(empty.BlocksHash, func(_ protocol.FileInfo) bool {
|
||||
count++
|
||||
return true
|
||||
})
|
||||
@@ -3343,7 +3343,7 @@ func TestRenameEmptyFile(t *testing.T) {
|
||||
}
|
||||
|
||||
count = 0
|
||||
snap.WithBlocksHash(file.BlocksHash, func(_ protocol.FileIntf) bool {
|
||||
snap.WithBlocksHash(file.BlocksHash, func(_ protocol.FileInfo) bool {
|
||||
count++
|
||||
return true
|
||||
})
|
||||
@@ -3362,7 +3362,7 @@ func TestRenameEmptyFile(t *testing.T) {
|
||||
defer snap.Release()
|
||||
|
||||
count = 0
|
||||
snap.WithBlocksHash(empty.BlocksHash, func(_ protocol.FileIntf) bool {
|
||||
snap.WithBlocksHash(empty.BlocksHash, func(_ protocol.FileInfo) bool {
|
||||
count++
|
||||
return true
|
||||
})
|
||||
@@ -3372,7 +3372,7 @@ func TestRenameEmptyFile(t *testing.T) {
|
||||
}
|
||||
|
||||
count = 0
|
||||
snap.WithBlocksHash(file.BlocksHash, func(i protocol.FileIntf) bool {
|
||||
snap.WithBlocksHash(file.BlocksHash, func(i protocol.FileInfo) bool {
|
||||
count++
|
||||
if i.FileName() != "new-file" {
|
||||
t.Fatalf("unexpected file name %s, expected new-file", i.FileName())
|
||||
@@ -3408,7 +3408,7 @@ func TestBlockListMap(t *testing.T) {
|
||||
}
|
||||
var paths []string
|
||||
|
||||
snap.WithBlocksHash(fi.BlocksHash, func(fi protocol.FileIntf) bool {
|
||||
snap.WithBlocksHash(fi.BlocksHash, func(fi protocol.FileInfo) bool {
|
||||
paths = append(paths, fi.FileName())
|
||||
return true
|
||||
})
|
||||
@@ -3441,7 +3441,7 @@ func TestBlockListMap(t *testing.T) {
|
||||
defer snap.Release()
|
||||
|
||||
paths = paths[:0]
|
||||
snap.WithBlocksHash(fi.BlocksHash, func(fi protocol.FileIntf) bool {
|
||||
snap.WithBlocksHash(fi.BlocksHash, func(fi protocol.FileInfo) bool {
|
||||
paths = append(paths, fi.FileName())
|
||||
return true
|
||||
})
|
||||
@@ -3468,7 +3468,7 @@ func TestScanRenameCaseOnly(t *testing.T) {
|
||||
snap := dbSnapshot(t, m, fcfg.ID)
|
||||
defer snap.Release()
|
||||
found := false
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileIntf) bool {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileInfo) bool {
|
||||
if found {
|
||||
t.Fatal("got more than one file")
|
||||
}
|
||||
@@ -3487,7 +3487,7 @@ func TestScanRenameCaseOnly(t *testing.T) {
|
||||
snap = dbSnapshot(t, m, fcfg.ID)
|
||||
defer snap.Release()
|
||||
found = false
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileIntf) bool {
|
||||
snap.WithHave(protocol.LocalDeviceID, func(i protocol.FileInfo) bool {
|
||||
if i.FileName() == name {
|
||||
if i.IsDeleted() {
|
||||
return true
|
||||
|
||||
@@ -12,6 +12,9 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/syncthing/syncthing/internal/protoutil"
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
"github.com/syncthing/syncthing/lib/osutil"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
@@ -386,7 +389,7 @@ func writeEncryptionTrailer(file protocol.FileInfo, writer io.WriterAt) (int64,
|
||||
|
||||
trailerSize := encryptionTrailerSize(wireFile)
|
||||
bs := make([]byte, trailerSize)
|
||||
n, err := wireFile.MarshalTo(bs)
|
||||
n, err := protoutil.MarshalTo(bs, wireFile.ToWire(false))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -401,7 +404,7 @@ func writeEncryptionTrailer(file protocol.FileInfo, writer io.WriterAt) (int64,
|
||||
}
|
||||
|
||||
func encryptionTrailerSize(file protocol.FileInfo) int64 {
|
||||
return int64(file.ProtoSize()) + 4
|
||||
return int64(proto.Size(file.ToWire(false))) + 4 // XXX: Inefficient
|
||||
}
|
||||
|
||||
// Progress returns the momentarily progress for the puller
|
||||
|
||||
@@ -75,7 +75,7 @@ func init() {
|
||||
},
|
||||
Defaults: config.Defaults{
|
||||
Folder: config.FolderConfiguration{
|
||||
FilesystemType: fs.FilesystemTypeFake,
|
||||
FilesystemType: config.FilesystemTypeFake,
|
||||
Path: rand.String(32),
|
||||
},
|
||||
},
|
||||
@@ -102,7 +102,7 @@ func newDefaultCfgWrapper() (config.Wrapper, config.FolderConfiguration, context
|
||||
}
|
||||
|
||||
func newFolderConfig() config.FolderConfiguration {
|
||||
cfg := newFolderConfiguration(defaultCfgWrapper, "default", "default", fs.FilesystemTypeFake, rand.String(32)+"?content=true")
|
||||
cfg := newFolderConfiguration(defaultCfgWrapper, "default", "default", config.FilesystemTypeFake, rand.String(32)+"?content=true")
|
||||
cfg.FSWatcherEnabled = false
|
||||
cfg.Devices = append(cfg.Devices, config.FolderDeviceConfiguration{DeviceID: device1})
|
||||
return cfg
|
||||
|
||||
Reference in New Issue
Block a user