Add flush method to SweepstoreFileHandle for improved data synchronization

This commit is contained in:
ImBenji
2025-12-02 15:24:01 +00:00
parent 5d9b34e030
commit 82efc4a524
3 changed files with 21 additions and 3 deletions

View File

@@ -88,7 +88,7 @@ void SweepstoreHeader::initialise() {
writeAddressTablePointer(SweepstorePointer::NULL_PTR);
writeFreeListCount(0);
writeIsFreeListLifted(false);
file->flush();
file.flush();
}
uint64_t SweepstoreConcurrencyHeader::readMasterIdentifier() {
@@ -158,7 +158,7 @@ void SweepstoreConcurrencyHeader::initialise(int concurrentWorkers) {
SweepstoreWorkerTicket ticketWriter = SweepstoreWorkerTicket(i, file);
ticketWriter.write(ticket);
}
file->flush();
file.flush();
}
void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
@@ -189,7 +189,7 @@ void SweepstoreWorkerTicket::write(SweepstoreWorkerTicketSnapshot &snapshot) {
// Write to file
file.writeSeek(getOffset());
file.writeBytes(dataPtr, data.size());
file->flush();
file.flush();
}
bool SweepstoreWorkerTicket::writable() {

View File

@@ -55,6 +55,23 @@ void SweepstoreFileHandle::close() {
#endif
}
// flush
void SweepstoreFileHandle::flush() {
#ifdef WITH_UNREAL
if (unrealHandle) {
unrealHandle->Flush();
}
#else
if (stream) {
stream->flush();
#ifdef _WIN32
// On Windows, also sync to ensure data hits disk
stream->sync();
#endif
}
#endif
}
#if defined(_WIN32) || defined(WITH_UNREAL)
// readSeek
void SweepstoreFileHandle::readSeek(std::streampos pos, std::ios::seekdir dir) {

View File

@@ -37,6 +37,7 @@ public:
bool isOpen() const;
void close();
void flush();
// Windows-compatible I/O wrappers
#if defined(_WIN32) || defined(WITH_UNREAL)