Managers: make BackupManager::scanSubdir() actually work.
This commit is contained in:
parent
902e31e160
commit
ccbafe5e30
1 changed files with 11 additions and 10 deletions
|
@ -225,10 +225,12 @@ void
|
||||||
BackupManager::scanSubdir(Containers::StringView subdir) {
|
BackupManager::scanSubdir(Containers::StringView subdir) {
|
||||||
static std::uint8_t depth = 0;
|
static std::uint8_t depth = 0;
|
||||||
|
|
||||||
|
auto full_subdir = Utility::Path::join(conf().directories().backups, subdir);
|
||||||
|
|
||||||
using Flag = Utility::Path::ListFlag;
|
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) {
|
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{
|
auto predicate = [](Containers::StringView file)->bool{
|
||||||
|
@ -241,9 +243,9 @@ BackupManager::scanSubdir(Containers::StringView subdir) {
|
||||||
zip_t* zip;
|
zip_t* zip;
|
||||||
for(Containers::StringView file : files_view) {
|
for(Containers::StringView file : files_view) {
|
||||||
Backup backup;
|
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) {
|
if(zip == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -301,16 +303,15 @@ BackupManager::scanSubdir(Containers::StringView subdir) {
|
||||||
arrayAppend(_backups, Utility::move(backup));
|
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) {
|
if(depth == 5) {
|
||||||
return;
|
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++;
|
depth++;
|
||||||
|
|
||||||
for(auto& dir : *subdirs) {
|
for(auto& dir : *subdirs) {
|
||||||
|
|
Loading…
Reference in a new issue