diff --git a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp index 7f641eb67..712420a5e 100644 --- a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp +++ b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp @@ -49,7 +49,7 @@ namespace sts::ncm::impl { if (found_cache) { /* Flush and close */ - fsync(fileno(found_cache->handle)); + fflush(found_cache->handle)); fclose(found_cache->handle); std::fill(found_cache->id.uuid, found_cache->id.uuid + sizeof(PlaceHolderId), 0); } @@ -196,7 +196,7 @@ namespace sts::ncm::impl { /* Find an empty cache */ for (size_t i = 0; i < MaxCaches; i++) { - if (placeholder_id != InvalidUuid) { + if (placeholder_id == InvalidUuid) { cache = &this->caches[i]; break; } @@ -208,7 +208,7 @@ namespace sts::ncm::impl { /* Flush and close any handles. */ if (cache->handle) { - fsync(fileno(cache->handle)); + fflush(cache->handle); fclose(cache->handle); } cache->id = InvalidUuid; @@ -226,7 +226,7 @@ namespace sts::ncm::impl { CacheEntry* cache = &this->caches[i]; if (cache->id != InvalidUuid) { - fsync(fileno(cache->handle)); + fflush(cache->handle)); fclose(cache->handle); cache->id = InvalidUuid; } diff --git a/stratosphere/ncm/source/ncm_contentstorage.cpp b/stratosphere/ncm/source/ncm_contentstorage.cpp index 08083a00e..1f1da11e7 100644 --- a/stratosphere/ncm/source/ncm_contentstorage.cpp +++ b/stratosphere/ncm/source/ncm_contentstorage.cpp @@ -163,8 +163,8 @@ namespace sts::ncm { fseek(f, offset, SEEK_SET); fwrite(data.buffer, sizeof(u8), data.num_elements, f); - if (this->placeholder_accessor.delay_flush ^ 1) { - fsync(fileno(f)); + if (!this->placeholder_accessor.delay_flush) { + fflush(f)); } this->placeholder_accessor.FlushCache(f, placeholder_id); @@ -598,7 +598,7 @@ namespace sts::ncm { fseek(f, offset, SEEK_SET); fwrite(data.buffer, sizeof(u8), data.num_elements, f); - fsync(fileno(f)); + fflush(f)); if (errno != 0) { return fsdevGetLastResult();