aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/cache/Cache.hx
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/cache/Cache.hx')
-rw-r--r--src/server/cache/Cache.hx28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/server/cache/Cache.hx b/src/server/cache/Cache.hx
index f71b465..56749d8 100644
--- a/src/server/cache/Cache.hx
+++ b/src/server/cache/Cache.hx
@@ -39,19 +39,37 @@ class Cache {
cachedFiles.resize(0);
for (name in names) cachedFiles.push(name);
+ removeUntrackedFiles();
+ }
+
+ function removeUntrackedFiles():Void {
final names = FileSystem.readDirectory(cacheDir);
for (name in names) {
if (name.startsWith(".")) continue;
if (FileSystem.isDirectory('$cacheDir/$name')) continue;
if (cachedFiles.contains(name)) continue;
- trace('Remove non-tracked cache $name');
+ trace('Remove untracked cache $name');
remove(name);
}
}
public function log(client:Client, msg:String):Void {
+ trace(msg);
main.serverMessage(client, msg);
+ }
+
+ public function logByName(clientName:String, msg:String):Void {
trace(msg);
+ final client = main.clients.getByName(clientName) ?? return;
+ main.serverMessage(client, msg);
+ }
+
+ public function logWithAdmins(client:Client, msg:String):Void {
+ log(client, msg);
+ final admins = main.clients.filter(client -> client.isAdmin);
+ for (admin in admins) {
+ if (client != admin) main.serverMessage(admin, msg);
+ }
}
public function cacheYoutubeVideo(client:Client, url:String, callback:(name:String) -> Void) {
@@ -152,6 +170,14 @@ class Cache {
return FileSystem.exists(getFilePath(name));
}
+ public function findFile(callback:(name:String) -> Bool):Null<String> {
+ final names = FileSystem.readDirectory(cacheDir);
+ for (name in names) {
+ if (callback(name)) return name;
+ }
+ return null;
+ }
+
public function getFreeSpace():Int {
return storageLimit - getUsedSpace();
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage