mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 07:12:27 +00:00
This commit is contained in:
parent
e56e8b7aa1
commit
50aacdf1f0
@ -122,10 +122,10 @@ func (f FileInfo) FileSize() int64 {
|
||||
}
|
||||
|
||||
func (f FileInfo) BlockSize() int {
|
||||
if f.RawBlockSize == 0 {
|
||||
if f.RawBlockSize < MinBlockSize {
|
||||
return MinBlockSize
|
||||
}
|
||||
return int(f.RawBlockSize)
|
||||
return f.RawBlockSize
|
||||
}
|
||||
|
||||
func (f FileInfo) FileName() string {
|
||||
|
@ -319,17 +319,19 @@ func encryptFileInfo(fi FileInfo, folderKey *[keySize]byte) FileInfo {
|
||||
enc := FileInfo{
|
||||
Name: encryptName(fi.Name, folderKey),
|
||||
Type: typ,
|
||||
Size: offset, // new total file size
|
||||
Permissions: 0644,
|
||||
ModifiedS: 1234567890, // Sat Feb 14 00:31:30 CET 2009
|
||||
Deleted: fi.Deleted,
|
||||
RawInvalid: fi.IsInvalid(),
|
||||
Version: version,
|
||||
Sequence: fi.Sequence,
|
||||
RawBlockSize: fi.RawBlockSize + blockOverhead,
|
||||
Blocks: blocks,
|
||||
Encrypted: encryptedFI,
|
||||
}
|
||||
if typ == FileInfoTypeFile {
|
||||
enc.Size = offset // new total file size
|
||||
enc.Blocks = blocks
|
||||
enc.RawBlockSize = fi.BlockSize() + blockOverhead
|
||||
}
|
||||
|
||||
return enc
|
||||
}
|
||||
|
@ -142,6 +142,9 @@ func TestEnDecryptFileInfo(t *testing.T) {
|
||||
if bytes.Equal(enc.Blocks[0].Hash, enc.Blocks[1].Hash) {
|
||||
t.Error("block hashes should not repeat when on different offsets")
|
||||
}
|
||||
if enc.RawBlockSize < MinBlockSize {
|
||||
t.Error("Too small raw block size:", enc.RawBlockSize)
|
||||
}
|
||||
again := encryptFileInfo(fi, &key)
|
||||
if !bytes.Equal(enc.Blocks[0].Hash, again.Blocks[0].Hash) {
|
||||
t.Error("block hashes should remain stable (0)")
|
||||
|
Loading…
Reference in New Issue
Block a user