Fix a few path/folder related issues with paged article. Also improved a few error messages.

This commit is contained in:
Relintai 2021-02-08 11:53:04 +01:00
parent 42758e57ad
commit 9a3404a7ac
3 changed files with 11 additions and 6 deletions

View File

@ -27,7 +27,7 @@ void FileCache::wwwroot_evaluate_dir(const char *path, const bool should_exist)
if (tinydir_open(&dir, path) == -1) { if (tinydir_open(&dir, path) == -1) {
if (should_exist) if (should_exist)
printf("Error opening wwwroot!\n"); printf("Error opening wwwroot! folder: %s\n", path);
return; return;
} }

View File

@ -30,7 +30,7 @@ void ListPage::load() {
tinydir_dir dir; tinydir_dir dir;
if (tinydir_open(&dir, folder.c_str()) == -1) { if (tinydir_open(&dir, folder.c_str()) == -1) {
printf("Error opening ListPage::folder!\n"); printf("Error opening ListPage::folder! folder: %s\n", folder.c_str());
return; return;
} }

View File

@ -67,9 +67,13 @@ void PagedArticle::load() {
base_path.pop_back(); base_path.pop_back();
} }
if (folder.size() > 0 && folder[folder.size() - 1] == '/') {
folder.pop_back();
}
tinydir_dir dir; tinydir_dir dir;
if (tinydir_open(&dir, folder.c_str()) == -1) { if (tinydir_open(&dir, folder.c_str()) == -1) {
printf("Error opening PagedArticle::folder!\n"); printf("Error opening PagedArticle::folder! folder: %s\n", folder.c_str());
return; return;
} }
@ -89,9 +93,10 @@ void PagedArticle::load() {
std::string np = file.path; std::string np = file.path;
std::string fn = file.name; std::string fn = file.name;
std::string ff = base_path + "/" + fn; std::string ff = folder + "/" + fn;
std::string wp = base_path + "/" + fn;
Article *a = load_folder(np, ff); Article *a = load_folder(np, wp);
if (a) { if (a) {
@ -101,7 +106,7 @@ void PagedArticle::load() {
pages[p] = a; pages[p] = a;
} }
a->file_cache->wwwroot = ("." + ff + "/files"); a->file_cache->wwwroot = (ff + "/files");
a->file_cache->wwwroot_refresh_cache(); a->file_cache->wwwroot_refresh_cache();
} }