Update dmd version + dependencies

This commit is contained in:
Chris Josten 2023-12-08 22:52:11 +01:00
parent bdb7615044
commit 651668526d
7 changed files with 50 additions and 25 deletions

View file

@ -5,17 +5,19 @@
"botan-math": "1.0.3", "botan-math": "1.0.3",
"diet-ng": "1.8.1", "diet-ng": "1.8.1",
"dyaml": "0.8.6", "dyaml": "0.8.6",
"eventcore": "0.9.20", "eventcore": "0.9.26",
"fswatch": "0.5.0", "fswatch": "0.5.0",
"libasync": "0.8.6", "libasync": "0.8.6",
"libevent": "2.0.2+2.0.16", "libevent": "2.0.2+2.0.16",
"memutils": "1.0.4", "memutils": "1.0.9",
"mir-linux-kernel": "1.0.1", "mir-linux-kernel": "1.0.1",
"openssl": "3.2.2", "openssl": "3.3.3",
"openssl-static": "1.0.2+3.0.8",
"stdx-allocator": "2.77.5", "stdx-allocator": "2.77.5",
"taggedalgebraic": "0.11.22", "taggedalgebraic": "0.11.22",
"tinyendian": "0.2.0", "tinyendian": "0.2.0",
"vibe-core": "1.22.4", "vibe-container": "1.0.1",
"vibe-d": "0.9.5" "vibe-core": "2.5.1",
"vibe-d": "0.9.7"
} }
} }

View file

@ -5,6 +5,7 @@ import article;
import page; import page;
import project; import project;
@safe:
/** /**
* Default ordering and list with pointers to ordered articles. * Default ordering and list with pointers to ordered articles.

View file

@ -9,19 +9,29 @@ import cache;
import http; import http;
import watcher; import watcher;
void watchTask(T, C)(C *cache, string directory) @safe nothrow {
do {
try {
initPages!T(cache, directory);
} catch(Exception e) {
logWarn("Error while watching pages: " ~ e.msg);
}
} while(Task.getThis().running);
}
void main() { void main() {
startHTTPServer(); startHTTPServer();
// Start indexing pages. // Start indexing pages.
runTask({ runTask({
initPages!Page(&pages, "pages"); watchTask!Page(&pages, "pages");
}); });
runTask({ runTask({
initPages!Article(&articles, "articles"); watchTask!Article(&articles, "articles");
}); });
runTask({ runTask({
initPages!Project(&projects, "projects"); watchTask!Project(&projects, "projects");
}); });
runApplication(); runApplication();
} }

View file

@ -10,6 +10,7 @@ import vibe.d;
import page; import page;
import utils; import utils;
@safe:
/** /**
* Represents an article on the blog * Represents an article on the blog

View file

@ -9,6 +9,7 @@ import vibe.vibe;
import utils; import utils;
@safe:
/** /**
* Exception thrown when a page has syntax errors e.g. * Exception thrown when a page has syntax errors e.g.
@ -51,7 +52,7 @@ class Page {
/** /**
* Creates a page from a file. This will read from the file and parse it. * Creates a page from a file. This will read from the file and parse it.
*/ */
this(string file) { this(string file) @safe {
this.m_name = file; this.m_name = file;
this.m_contentSource = readText(file); this.m_contentSource = readText(file);
// Find the seperator and split the string in two // Find the seperator and split the string in two

View file

@ -9,6 +9,8 @@ import page;
import utils; import utils;
import staticpaths; import staticpaths;
@safe:
/** /**
* Represents a project, like an unfinished application * Represents a project, like an unfinished application
*/ */

View file

@ -1,6 +1,6 @@
import std.array; import std.array;
import std.algorithm; import std.algorithm;
import std.experimental.logger; //import std.experimental.logger;
import std.file; import std.file;
import std.stdio; import std.stdio;
import std.traits; import std.traits;
@ -13,27 +13,35 @@ import page;
/** /**
* Loads pages into memory and sets up a "watcher" to watch a directory for file changes. * Loads pages into memory and sets up a "watcher" to watch a directory for file changes.
*/ */
void initPages(T, C)(C *cache, const string directory) void initPages(T, C)(C *cache, const string directory) @trusted
if (isImplicitlyConvertible!(T, Page)) { if (isImplicitlyConvertible!(T, Page)) {
NativePath watchingDir;
try {
watchingDir = getWorkingDirectory() ~ directory;
} catch(PathValidationException) {
logError("Cannot watch path " ~ directory);
return;
}
bool addPage(string path) { bool addPage(string path) {
try { try {
T newPage = new T(path); T newPage = new T(path);
logf("Added %s", newPage.slug); logInfo("Added %s", newPage.slug);
cache.addItem(newPage); cache.addItem(newPage);
return true; return true;
} catch (page.ArticleParseException e) { } catch (page.ArticleParseException e) {
logf("Could not parse %s: %s", path, e); logWarn("Could not parse %s: %s", path, e);
return false; return false;
} catch (Exception e) { } catch (Exception e) {
logf("Other exception while parsing %s: %s", path, e); logWarn("Other exception while parsing %s: %s", path, e);
return false; return false;
} }
} }
// Initial scan // Initial scan
void scan(NativePath path, int level = 0) { void scan(NativePath path, int level = 0) {
logf("Scanning %s", path.toString()); logInfo("Scanning %s", path.toString());
foreach(file; iterateDirectory(path)) { foreach(file; iterateDirectory(path)) {
if (file.isDirectory) { if (file.isDirectory) {
scan(path ~ file.name, level + 1); scan(path ~ file.name, level + 1);
@ -43,11 +51,11 @@ void initPages(T, C)(C *cache, const string directory)
} }
} }
if (!existsFile(getWorkingDirectory() ~ directory)) { if (!existsFile(watchingDir)) {
createDirectory(getWorkingDirectory() ~ directory); createDirectory(watchingDir);
} }
scan(getWorkingDirectory() ~ directory); scan(watchingDir);
DirectoryWatcher watcher = watchDirectory(getWorkingDirectory() ~ directory, true); DirectoryWatcher watcher = watchDirectory(watchingDir, true);
bool shouldStop = false; bool shouldStop = false;
while (!shouldStop) { while (!shouldStop) {
@ -55,16 +63,16 @@ void initPages(T, C)(C *cache, const string directory)
DirectoryChange[] changes; DirectoryChange[] changes;
shouldStop = !watcher.readChanges(changes); shouldStop = !watcher.readChanges(changes);
foreach(change; changes) { foreach(change; changes) {
logf("=======[New changes]======"); logInfo("=======[New changes]======");
string[] changeTypes = ["added", "removed", "modified"]; string[] changeTypes = ["added", "removed", "modified"];
logf("Path: %s, type: %s", change.path.toString(), changeTypes[change.type]); logInfo("Path: %s, type: %s", change.path.toString(), changeTypes[change.type]);
if (endsWith(change.path.toString(), ".kate-swp")) continue; if (endsWith(change.path.toString(), ".kate-swp")) continue;
switch (change.type) with (DirectoryChangeType){ switch (change.type) with (DirectoryChangeType){
case added: case added:
try { try {
addPage(change.path.toString()); addPage(change.path.toString());
} catch(Exception e) { } catch(Exception e) {
warningf("Error while updating %s: %s", change.path.toString(), e.msg); logWarn("Error while updating %s: %s", change.path.toString(), e.msg);
} }
break; break;
case modified: case modified:
@ -73,16 +81,16 @@ void initPages(T, C)(C *cache, const string directory)
newPage = new T(change.path.toString()); newPage = new T(change.path.toString());
cache.changeItem(newPage); cache.changeItem(newPage);
} catch(page.ArticleParseException e) { } catch(page.ArticleParseException e) {
warningf("Could not parse %s", change.path.toString()); logWarn("Could not parse %s", change.path.toString());
} catch (Exception e) { } catch (Exception e) {
warningf("Error while updating %s: %s", change.path.toString(), e.msg); logWarn("Error while updating %s: %s", change.path.toString(), e.msg);
} }
break; break;
case removed: case removed:
try { try {
cache.removeItemByName(change.path.toString()); cache.removeItemByName(change.path.toString());
} catch(Exception e) { } catch(Exception e) {
logf("Error while trying to remove %s: %s", T.stringof, e.msg); logInfo("Error while trying to remove %s: %s", T.stringof, e.msg);
} }
break; break;
default: break; default: break;