Fix crash on rebuild
Fixed a bug which caused SWG to crash when rebuilding a website which has been build before (a website with an existing "output" directory).
This commit is contained in:
parent
d424e85466
commit
46bd5333a8
|
@ -208,19 +208,30 @@ void build_website(SwgContext &ctx, std::string const &path) {
|
|||
getFilename(ws_entry.path()).length());
|
||||
if (!std::filesystem::exists(copied_subdir)) {
|
||||
std::filesystem::create_directories(copied_subdir);
|
||||
std::cout << "--> Creating: " << copied_subdir << "\n";
|
||||
std::cout << "Creating: " << copied_subdir << "\n";
|
||||
}
|
||||
// If this isn't a Markdown file, just copy it.
|
||||
if (currentFile.find(".md") == std::string::npos)
|
||||
bool compiled = false;
|
||||
if (currentFile.find(".md") == std::string::npos) {
|
||||
try {
|
||||
std::filesystem::copy(ws_entry, copied_subdir);
|
||||
else {
|
||||
} catch (std::filesystem::filesystem_error const &cpyErr) {
|
||||
// Ignore exception if it was
|
||||
// thrown due to an existing
|
||||
// file error while copying.
|
||||
if (cpyErr.code().value() != 17)
|
||||
throw cpyErr;
|
||||
}
|
||||
} else {
|
||||
// This is a Markdown file. Compile a HTML version.
|
||||
std::filesystem::path output_html = copied_subdir;
|
||||
// Remove the .md extension and use the HTML extension instead
|
||||
output_html /= currentFile.substr(0, currentFile.length() - 3) + ".html";
|
||||
compile_markdown(path, ws_entry.path(), output_html);
|
||||
compiled = true;
|
||||
}
|
||||
std::cout << "\t!: " << ws_entry.path().string().substr(path.length()) << "\n";
|
||||
std::cout << (compiled ? "Compiled: " : "Copied: ") <<
|
||||
ws_entry.path().string().substr(path.length()) << "\n";
|
||||
}
|
||||
}
|
||||
} catch (std::filesystem::filesystem_error const &e) {
|
||||
|
|
Loading…
Reference in New Issue