mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-13 00:36:28 +00:00
parent
3169212046
commit
bf7d03d029
@ -1695,6 +1695,7 @@ func (f *sendReceiveFolder) dbUpdaterRoutine(dbUpdateChan <-chan dbUpdateJob) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recvEnc := f.Type == config.FolderTypeReceiveEncrypted
|
||||||
loop:
|
loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -1706,6 +1707,9 @@ loop:
|
|||||||
switch job.jobType {
|
switch job.jobType {
|
||||||
case dbUpdateHandleFile, dbUpdateShortcutFile:
|
case dbUpdateHandleFile, dbUpdateShortcutFile:
|
||||||
changedDirs[filepath.Dir(job.file.Name)] = struct{}{}
|
changedDirs[filepath.Dir(job.file.Name)] = struct{}{}
|
||||||
|
if recvEnc {
|
||||||
|
job.file.Size += encryptionTrailerSize(job.file)
|
||||||
|
}
|
||||||
case dbUpdateHandleDir:
|
case dbUpdateHandleDir:
|
||||||
changedDirs[job.file.Name] = struct{}{}
|
changedDirs[job.file.Name] = struct{}{}
|
||||||
case dbUpdateHandleSymlink, dbUpdateInvalidate:
|
case dbUpdateHandleSymlink, dbUpdateInvalidate:
|
||||||
|
@ -192,7 +192,7 @@ func (s *sharedPullerState) tempFileInWritableDir(_ string) error {
|
|||||||
size := s.file.Size
|
size := s.file.Size
|
||||||
// Trailer added to encrypted files
|
// Trailer added to encrypted files
|
||||||
if len(s.file.Encrypted) > 0 {
|
if len(s.file.Encrypted) > 0 {
|
||||||
size += int64(s.file.ProtoSize() + 4)
|
size += encryptionTrailerSize(s.file)
|
||||||
}
|
}
|
||||||
// Truncate sets the size of the file. This creates a sparse file or a
|
// Truncate sets the size of the file. This creates a sparse file or a
|
||||||
// space reservation, depending on the underlying filesystem.
|
// space reservation, depending on the underlying filesystem.
|
||||||
@ -346,8 +346,7 @@ func (s *sharedPullerState) finalClose() (bool, error) {
|
|||||||
// folder from encrypted data we can extract this FileInfo from the end of
|
// folder from encrypted data we can extract this FileInfo from the end of
|
||||||
// the file and regain the original metadata.
|
// the file and regain the original metadata.
|
||||||
func (s *sharedPullerState) finalizeEncrypted() error {
|
func (s *sharedPullerState) finalizeEncrypted() error {
|
||||||
size := s.file.ProtoSize()
|
bs := make([]byte, encryptionTrailerSize(s.file))
|
||||||
bs := make([]byte, 4+size)
|
|
||||||
n, err := s.file.MarshalTo(bs)
|
n, err := s.file.MarshalTo(bs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -364,11 +363,13 @@ func (s *sharedPullerState) finalizeEncrypted() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
s.file.Size += int64(len(bs))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func encryptionTrailerSize(file protocol.FileInfo) int64 {
|
||||||
|
return int64(file.ProtoSize()) + 4
|
||||||
|
}
|
||||||
|
|
||||||
// Progress returns the momentarily progress for the puller
|
// Progress returns the momentarily progress for the puller
|
||||||
func (s *sharedPullerState) Progress() *pullerProgress {
|
func (s *sharedPullerState) Progress() *pullerProgress {
|
||||||
s.mut.RLock()
|
s.mut.RLock()
|
||||||
|
Loading…
Reference in New Issue
Block a user