From 8b96d885e4b8e00cd3ea479290b82557abef11b1 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Tue, 16 Jun 2020 02:01:01 -0500
Subject: [PATCH] Ender 3 V2 followup

---
 Marlin/src/sd/cardreader.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp
index aa0606705b..2631edf481 100644
--- a/Marlin/src/sd/cardreader.cpp
+++ b/Marlin/src/sd/cardreader.cpp
@@ -185,7 +185,7 @@ int CardReader::countItems(SdFile dir) {
   while (dir.readDir(&p, longFilename) > 0)
     c += is_dir_or_gcode(p);
 
-  #if ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES
+  #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES)
     nrFiles = c;
   #endif
 
@@ -430,7 +430,9 @@ void CardReader::release() {
   endFilePrint();
   flag.mounted = false;
   flag.workDirIsRoot = true;
-  nrFiles = 0;
+  #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES)
+    nrFiles = 0;
+  #endif
 }
 
 void CardReader::openAndPrintFile(const char *name) {