Skip to content

Commit

Permalink
Warn Termux users to move the session folder to $HOME, fix ogg conver…
Browse files Browse the repository at this point in the history
…sion with the phar version
  • Loading branch information
danog committed Feb 9, 2024
1 parent 0aa6f8c commit b764461
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class API extends AbstractAPI
*
* @var string
*/
public const RELEASE = '8.0.0-beta191';
public const RELEASE = '8.0.0-beta192';
/**
* We're not logged in.
*
Expand Down
10 changes: 9 additions & 1 deletion src/SessionPaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace danog\MadelineProto;

use AssertionError;
use danog\MadelineProto\Ipc\IpcState;

use const LOCK_EX;
Expand Down Expand Up @@ -101,8 +102,15 @@ public function __construct(string $session)
$this->ipcStatePath = $session.DIRECTORY_SEPARATOR."ipcState.php";
if (!exists($session)) {
createDirectory($session);
return;
}

$session = realpath($session);
if (str_starts_with($session, '/storage/emulated/')
|| str_starts_with($session, '/sdcard/')
) {
throw new AssertionError("The MadelineProto session folder cannot be stored in /sdcard, please move the session folder to the termux \$HOME folder, see here for more info: https://wiki.termux.com/wiki/Internal_and_external_storage");
}

if (!isDirectory($session) && isFile("$session.safe.php")) {
deleteFile($session);
createDirectory($session);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ public static function canConvertOgg(): bool
return self::$canConvert;
}
try {
Ogg::convert(new LocalFile(__DIR__.'/empty.wav'), new WritableBuffer);
Ogg::convert(new ReadableBuffer(file_get_contents(__DIR__.'/empty.wav')), new WritableBuffer);
self::$canConvert = true;
} catch (\Throwable $e) {
Logger::log("An error occurred while attempting conversion: $e");
Expand Down

0 comments on commit b764461

Please sign in to comment.