Skip to content

Commit 887e0a6

Browse files
committed
Fix cache bug for FAT16/FAT32
1 parent 4dbec4b commit 887e0a6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SdFat
2-
version=2.0.0
2+
version=2.0.1
33
license=MIT
44
author=Bill Greiman <fat16lib@sbcglobal.net>
55
maintainer=Bill Greiman <fat16lib@sbcglobal.net>

src/FatLib/FatFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ int FatFile::read(void* buf, size_t nbyte) {
764764
n = ns << m_vol->bytesPerSectorShift();
765765
// Check for cache sector in read range.
766766
if (sector <= m_vol->cacheSectorNumber()
767-
&& sector < (m_vol->cacheSectorNumber() + ns)) {
767+
&& m_vol->cacheSectorNumber() < (sector + ns)) {
768768
// Flush cache if cache sector is in the range.
769769
if (!m_vol->cacheSyncData()) {
770770
DBG_FAIL_MACRO;
@@ -1402,7 +1402,7 @@ size_t FatFile::write(const void* buf, size_t nbyte) {
14021402
n = nSector << m_vol->bytesPerSectorShift();
14031403
// Check for cache sector in write range.
14041404
if (sector <= m_vol->cacheSectorNumber()
1405-
&& sector < (m_vol->cacheSectorNumber() + nSector)) {
1405+
&& m_vol->cacheSectorNumber() < (sector + nSector)) {
14061406
// Invalidate cache if cache sector is in the range.
14071407
m_vol->cacheInvalidate();
14081408
}

0 commit comments

Comments
 (0)