Skip to content

Commit

Permalink
add schemaupdater heuristic to detect enc files
Browse files Browse the repository at this point in the history
  • Loading branch information
imsodin committed Nov 7, 2022
1 parent c20f442 commit 8be5288
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/db/schemaupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"

"github.com/syncthing/syncthing/lib/db/backend"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/protocol"
)

Expand Down Expand Up @@ -848,8 +849,24 @@ func (db *schemaUpdater) fixRecvEncFileSize(_ int) error {
for _, folderStr := range db.ListFolders() {
folder := []byte(folderStr)
var innerErr error
encParent := ""
err := t.withHave(folder, protocol.LocalDeviceID[:], nil, false, func(fi protocol.FileIntf) bool {
f := fi.(protocol.FileInfo)
switch f.Type {
case protocol.FileInfoTypeDirectory:
if protocol.IsEncryptedParent(fs.PathComponents(f.Name)) {
encParent = f.Name
} else {
encParent = ""
}
return true
case protocol.FileInfoTypeFile:
default:
return true
}
if !strings.HasPrefix(f.Name, encParent) {
return true
}
meta.removeFile(protocol.LocalDeviceID, f)
f.Size -= int64(f.ProtoSize())
meta.addFile(protocol.LocalDeviceID, f)
Expand Down

0 comments on commit 8be5288

Please sign in to comment.