refactor: remove tr_sys_file_flush() (#6647)

This commit is contained in:
Charles Kerr 2024-03-03 23:29:38 -06:00 committed by GitHub
parent 250f43ae68
commit efd6790973
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4 additions and 47 deletions

View File

@ -766,20 +766,6 @@ bool tr_sys_file_write_at(
return ret;
}
bool tr_sys_file_flush(tr_sys_file_t handle, tr_error* error)
{
TR_ASSERT(handle != TR_BAD_SYS_FILE);
bool const ret = (fsync(handle) != -1);
if (error != nullptr && !ret)
{
error->set_from_errno(errno);
}
return ret;
}
bool tr_sys_file_truncate(tr_sys_file_t handle, uint64_t size, tr_error* error)
{
TR_ASSERT(handle != TR_BAD_SYS_FILE);

View File

@ -1047,20 +1047,6 @@ bool tr_sys_file_write_at(
return ret;
}
bool tr_sys_file_flush(tr_sys_file_t handle, tr_error* error)
{
TR_ASSERT(handle != TR_BAD_SYS_FILE);
bool ret = FlushFileBuffers(handle);
if (!ret)
{
set_system_error(error, GetLastError());
}
return ret;
}
bool tr_sys_file_truncate(tr_sys_file_t handle, uint64_t size, tr_error* error)
{
TR_ASSERT(handle != TR_BAD_SYS_FILE);

View File

@ -417,17 +417,6 @@ bool tr_sys_file_write_at(
uint64_t* bytes_written,
tr_error* error = nullptr);
/**
* @brief Portability wrapper for `fsync()`.
*
* @param[in] handle Valid file descriptor.
* @param[out] error Pointer to error object. Optional, pass `nullptr` if you
* are not interested in error details.
*
* @return `True` on success, `false` otherwise (with `error` set accordingly).
*/
bool tr_sys_file_flush(tr_sys_file_t handle, tr_error* error = nullptr);
/**
* @brief Portability wrapper for `ftruncate()`.
*

View File

@ -55,12 +55,12 @@ int main(int argc, char** argv)
}
else
{
std::fclose(out);
std::remove(tmp_result_path.c_str());
(void)std::fclose(out);
(void)std::remove(tmp_result_path.c_str());
return 1;
}
std::fclose(out);
(void)std::fclose(out);
tr_sys_path_rename(tmp_result_path.c_str(), result_path.c_str());
return 0;
}

View File

@ -246,8 +246,6 @@ protected:
auto error = tr_error{};
auto const fd = tr_sys_file_open_temp(tmpl, &error);
blockingFileWrite(fd, payload, n, &error);
tr_sys_file_flush(fd, &error);
tr_sys_file_flush(fd, &error);
tr_sys_file_close(fd, &error);
if (error)
{
@ -274,8 +272,6 @@ protected:
0600,
nullptr);
blockingFileWrite(fd, payload, n);
tr_sys_file_flush(fd);
tr_sys_file_flush(fd);
tr_sys_file_close(fd);
sync();
@ -437,8 +433,8 @@ protected:
tr_sys_file_write(fd, &ch, 1, nullptr);
}
tr_sys_file_flush(fd);
tr_sys_file_close(fd);
sync();
}
}