finalizeEncrypted adds a trailer to the encrypted file containing the serialized FileInfo and the length of that FileInfo. When initializing a folder from encrypted data we can extract this FileInfo from the end of the file and regain the original metadata.
()
| 372 | // folder from encrypted data we can extract this FileInfo from the end of |
| 373 | // the file and regain the original metadata. |
| 374 | func (s *sharedPullerState) finalizeEncrypted() error { |
| 375 | trailerSize, err := writeEncryptionTrailer(s.file, s.writer) |
| 376 | if err != nil { |
| 377 | return err |
| 378 | } |
| 379 | s.file.Size += trailerSize |
| 380 | s.file.EncryptionTrailerSize = int(trailerSize) |
| 381 | return nil |
| 382 | } |
| 383 | |
| 384 | // Returns the size of the written trailer. |
| 385 | func writeEncryptionTrailer(file protocol.FileInfo, writer io.WriterAt) (int64, error) { |
no test coverage detected