diff options
| author | RblSb <msrblsb@gmail.com> | 2025-05-19 03:06:41 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2025-05-24 13:59:03 +0300 |
| commit | 623d85f88bb42834b335801ad5d703f6945d38d2 (patch) | |
| tree | 857983c5c90f429e4764e4880f95d8f12a0f4595 /src/server/cache/Cache.hx | |
| parent | 4b48de4f824ce48f1466014a9e9aa24023212181 (diff) | |
Migrate to yt-dlp
- yt-dlp should be more stable and allows more cool stuff in future
- easier to export cookies.txt with yt-dlp utility (cookies.json support removed)
- better quality fallback if not enough space
- keep progress reports after reconnections
Diffstat (limited to 'src/server/cache/Cache.hx')
| -rw-r--r-- | src/server/cache/Cache.hx | 28 |
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(); } |
