From ccbafe5e302cd24f37e76eebaee4433addc53d97 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Tue, 23 Apr 2024 21:26:26 +0200 Subject: [PATCH] Managers: make BackupManager::scanSubdir() actually work. --- src/Managers/BackupManager.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Managers/BackupManager.cpp b/src/Managers/BackupManager.cpp index a455e49..8187f0f 100644 --- a/src/Managers/BackupManager.cpp +++ b/src/Managers/BackupManager.cpp @@ -225,10 +225,12 @@ void BackupManager::scanSubdir(Containers::StringView subdir) { static std::uint8_t depth = 0; + auto full_subdir = Utility::Path::join(conf().directories().backups, subdir); + using Flag = Utility::Path::ListFlag; - auto files = Utility::Path::list(conf().directories().backups, Flag::SkipDirectories|Flag::SkipSpecial); + auto files = Utility::Path::list(full_subdir, Flag::SkipDirectories|Flag::SkipSpecial); if(!files) { - LOG_ERROR_FORMAT("Couldn't list contents of {}.", conf().directories().backups); + LOG_ERROR_FORMAT("Couldn't list contents of {}.", full_subdir); } auto predicate = [](Containers::StringView file)->bool{ @@ -241,9 +243,9 @@ BackupManager::scanSubdir(Containers::StringView subdir) { zip_t* zip; for(Containers::StringView file : files_view) { Backup backup; - backup.filename = Utility::Path::join(subdir, file); + backup.filename = Utility::Path::join(full_subdir, file); - zip = zip_open(Utility::Path::join(conf().directories().backups, file).data(), ZIP_RDONLY, &error_code); + zip = zip_open(backup.filename.cbegin(), ZIP_RDONLY, &error_code); if(zip == nullptr) { continue; } @@ -301,16 +303,15 @@ BackupManager::scanSubdir(Containers::StringView subdir) { arrayAppend(_backups, Utility::move(backup)); } - auto subdirs = Utility::Path::list(conf().directories().backups, - Flag::SkipFiles|Flag::SkipSpecial|Flag::SkipDotAndDotDot); - if(!subdirs) { - LOG_ERROR_FORMAT("Couldn't list contents of {}.", conf().directories().backups); - } - if(depth == 5) { return; } + auto subdirs = Utility::Path::list(full_subdir, Flag::SkipFiles|Flag::SkipSpecial|Flag::SkipDotAndDotDot); + if(!subdirs) { + LOG_ERROR_FORMAT("Couldn't list contents of {}.", full_subdir); + } + depth++; for(auto& dir : *subdirs) {