Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
download_store: ensure that session files land on the disk
Currently, save() stores session to the disk by: - serialize to bencode and write to files with .new ext - validate the new files - rename new files, removing .new ext Technically, this is done to make sure that session files on the disk are always valid/uncorrupted. However, if catastrophic events happen during save(), such as system crash / power outage, the actual content of session files may not have been synced to the disk. To make things much worse, rename() is atomic. That means we discarded the previous session files without actually landing the new session files on the disk, and we got a bunch of empty session files to deal with. This commit adds a fsync step to ensure that session files land on the disk.
- Loading branch information