From 887e0a67300f98f7e0b16dc278055c6c4fd002ba Mon Sep 17 00:00:00 2001 From: Bill Greiman Date: Tue, 10 Nov 2020 06:48:22 -0800 Subject: [PATCH] Fix cache bug for FAT16/FAT32 --- library.properties | 2 +- src/FatLib/FatFile.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.properties b/library.properties index 550fabab..e5fd70cb 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SdFat -version=2.0.0 +version=2.0.1 license=MIT author=Bill Greiman maintainer=Bill Greiman diff --git a/src/FatLib/FatFile.cpp b/src/FatLib/FatFile.cpp index fc39e5fa..d0aaf54a 100644 --- a/src/FatLib/FatFile.cpp +++ b/src/FatLib/FatFile.cpp @@ -764,7 +764,7 @@ int FatFile::read(void* buf, size_t nbyte) { n = ns << m_vol->bytesPerSectorShift(); // Check for cache sector in read range. if (sector <= m_vol->cacheSectorNumber() - && sector < (m_vol->cacheSectorNumber() + ns)) { + && m_vol->cacheSectorNumber() < (sector + ns)) { // Flush cache if cache sector is in the range. if (!m_vol->cacheSyncData()) { DBG_FAIL_MACRO; @@ -1402,7 +1402,7 @@ size_t FatFile::write(const void* buf, size_t nbyte) { n = nSector << m_vol->bytesPerSectorShift(); // Check for cache sector in write range. if (sector <= m_vol->cacheSectorNumber() - && sector < (m_vol->cacheSectorNumber() + nSector)) { + && m_vol->cacheSectorNumber() < (sector + nSector)) { // Invalidate cache if cache sector is in the range. m_vol->cacheInvalidate(); }