Skip to content

Commit

Permalink
Fix cache bug for FAT16/FAT32
Browse files Browse the repository at this point in the history
  • Loading branch information
greiman committed Nov 10, 2020
1 parent 4dbec4b commit 887e0a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SdFat
version=2.0.0
version=2.0.1
license=MIT
author=Bill Greiman <[email protected]>
maintainer=Bill Greiman <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions src/FatLib/FatFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 887e0a6

Please sign in to comment.