mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-30 04:19:13 +01:00
Fix unlinkSessionFile method
This commit is contained in:
parent
cebb56ee28
commit
7c833ba904
@ -2,6 +2,7 @@
|
||||
|
||||
namespace TelegramApiServer\MadelineProtoExtensions;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Promise;
|
||||
use danog\MadelineProto;
|
||||
use danog\MadelineProto\MTProto;
|
||||
@ -100,11 +101,16 @@ class SystemApiExtensions
|
||||
$file = Files::getSessionFile($session);
|
||||
|
||||
if (is_file($file)) {
|
||||
yield \Amp\File\unlink($file);
|
||||
yield \Amp\File\unlink($file . '.lock');
|
||||
$promises = [];
|
||||
foreach (glob("$file*") as $file) {
|
||||
$promises[] = \Amp\File\unlink($file);
|
||||
}
|
||||
yield from $promises;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Session file not found');
|
||||
}
|
||||
|
||||
yield from $this->unlinkSessionSettings($session);
|
||||
yield $this->unlinkSessionSettings($session);
|
||||
|
||||
return 'ok';
|
||||
});
|
||||
@ -129,6 +135,11 @@ class SystemApiExtensions
|
||||
});
|
||||
}
|
||||
|
||||
public function exit(): string {
|
||||
Loop::defer(static fn() => exit());
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
private function bytesToHuman($bytes): string
|
||||
{
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||
|
Loading…
Reference in New Issue
Block a user