From 14ab50defb2c6b06aec9a1401154fc57e662fc9d Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Mon, 5 Jul 2021 12:32:14 -0400 Subject: common: fs: file: Revert Flush to its previous behavior and add Commit It became apparent that logging can continuously spam errors that trigger file flushing. Since committing the files to disk is an expensive operation, this causes unnecessarily high disk usage. As such, we will revert Flush() to the previous behavior and add a Commit() member function in the event that this behavior is needed. --- src/common/fs/file.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/common/fs/file.h') diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 588fe619d..2c4ab4332 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h @@ -396,12 +396,21 @@ public: [[nodiscard]] size_t WriteString(std::span string) const; /** - * Attempts to flush any unwritten buffered data into the file and flush the file into the disk. + * Attempts to flush any unwritten buffered data into the file. * * @returns True if the flush was successful, false otherwise. */ bool Flush() const; + /** + * Attempts to commit the file into the disk. + * Note that this is an expensive operation as this forces the operating system to write + * the contents of the file associated with the file descriptor into the disk. + * + * @returns True if the commit was successful, false otherwise. + */ + bool Commit() const; + /** * Resizes the file to a given size. * If the file is resized to a smaller size, the remainder of the file is discarded. -- cgit v1.2.3