From f6d2b7442b7298cd04801c1616d0823d47b0eea9 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sat, 9 May 2026 00:15:28 +0200 Subject: [PATCH] Allow (empty) directory removal --- src/activities/home/FileBrowserActivity.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/activities/home/FileBrowserActivity.cpp b/src/activities/home/FileBrowserActivity.cpp index 0cb28fd2..c59f3ade 100644 --- a/src/activities/home/FileBrowserActivity.cpp +++ b/src/activities/home/FileBrowserActivity.cpp @@ -230,19 +230,21 @@ void FileBrowserActivity::loop() { const std::string& entry = files[selectorIndex]; const bool isDirectory = (entry.back() == '/'); + std::string entryName = entry; if (isDirectory) { - return; + entryName.pop_back(); } std::string cleanBase = basepath; if (cleanBase.back() != '/') cleanBase += "/"; - const std::string fullPath = cleanBase + entry; + const std::string fullPath = cleanBase + entryName; - auto handler = [this, fullPath](const ActivityResult& res) { + auto handler = [this, fullPath, isDirectory](const ActivityResult& res) { if (!res.isCancelled) { LOG_DBG("FileBrowser", "Attempting to delete: %s", fullPath.c_str()); clearFileMetadata(fullPath); - if (Storage.remove(fullPath.c_str())) { + const bool deleted = isDirectory ? Storage.removeDir(fullPath.c_str()) : Storage.remove(fullPath.c_str()); + if (deleted) { LOG_DBG("FileBrowser", "Deleted successfully"); loadFiles(); if (files.empty()) { @@ -252,7 +254,7 @@ void FileBrowserActivity::loop() { } requestUpdate(true); } else { - LOG_ERR("FileBrowser", "Failed to delete file: %s", fullPath.c_str()); + LOG_ERR("FileBrowser", "Failed to delete: %s", fullPath.c_str()); } } else { LOG_DBG("FileBrowser", "Delete cancelled by user");