mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-06 03:50:18 +02:00
fix(adb): close writable stream when closing AdbDaemonTransport
This commit is contained in:
parent
637d1f9bf8
commit
e185d6a7c6
3 changed files with 28 additions and 6 deletions
|
@ -285,7 +285,7 @@ Creates an `AdbSync` client. The client can send multiple command in sequence, a
|
||||||
public async lstat(path: string): Promise<AdbSyncStat>;
|
public async lstat(path: string): Promise<AdbSyncStat>;
|
||||||
```
|
```
|
||||||
|
|
||||||
Gets the information of a file or folder. If path is a symbolic link, the returned information is about the link itself.
|
Gets the information of a file or folder. If `path` points to a symbolic link, the returned information is about the link itself.
|
||||||
|
|
||||||
This uses the `STAT` or `LST2` (when supported) sync commands, notice that despite the name of `STAT`, it doesn't resolve symbolic links.
|
This uses the `STAT` or `LST2` (when supported) sync commands, notice that despite the name of `STAT`, it doesn't resolve symbolic links.
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ Same as the [`lstat`](https://linux.die.net/man/2/lstat) system call in Linux.
|
||||||
public async stat(path: string): Promise<AdbSyncStat>;
|
public async stat(path: string): Promise<AdbSyncStat>;
|
||||||
```
|
```
|
||||||
|
|
||||||
Similar to `lstat`, but if path is a symbolic link, the information is about the file it refers to.
|
Gets the information of a file or folder. If `path` points to a symbolic link, it will be resolved and the returned information is about the target.
|
||||||
|
|
||||||
Uses the `STA2` sync command, which requires the `stat_v2` feature flag. Will throw an error if device doesn't support that.
|
Uses the `STA2` sync command, which requires the `stat_v2` feature flag. Will throw an error if device doesn't support that.
|
||||||
|
|
||||||
|
@ -309,7 +309,9 @@ Same as the `stat` system call in Linux.
|
||||||
public async isDirectory(path: string): Promise<boolean>
|
public async isDirectory(path: string): Promise<boolean>
|
||||||
```
|
```
|
||||||
|
|
||||||
Uses `lstat` method to check if the given path is a directory.
|
Checks if `path` is a directory, or a symbolic link to a directory.
|
||||||
|
|
||||||
|
This uses `lstat` internally, thus works on all Android versions.
|
||||||
|
|
||||||
#### `opendir`
|
#### `opendir`
|
||||||
|
|
||||||
|
|
|
@ -86,18 +86,33 @@ export class AdbSync extends AutoDisposable {
|
||||||
!this.fixedPushMkdir;
|
!this.fixedPushMkdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets information of a file or folder.
|
||||||
|
*
|
||||||
|
* If `path` points to a symbolic link, the returned information is about the link itself (with `type` being `LinuxFileType.Link`).
|
||||||
|
*/
|
||||||
async lstat(path: string): Promise<AdbSyncStat> {
|
async lstat(path: string): Promise<AdbSyncStat> {
|
||||||
return await adbSyncLstat(this._socket, path, this.supportsStat);
|
return await adbSyncLstat(this._socket, path, this.#supportsStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the information of a file or folder.
|
||||||
|
*
|
||||||
|
* If `path` points to a symbolic link, it will be resolved and the returned information is about the target (with `type` being `LinuxFileType.File` or `LinuxFileType.Directory`).
|
||||||
|
*/
|
||||||
async stat(path: string) {
|
async stat(path: string) {
|
||||||
if (!this.supportsStat) {
|
if (!this.#supportsStat) {
|
||||||
throw new Error("Not supported");
|
throw new Error("Not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await adbSyncStat(this._socket, path);
|
return await adbSyncStat(this._socket, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `path` is a directory, or a symbolic link to a directory.
|
||||||
|
*
|
||||||
|
* This uses `lstat` internally, thus works on all Android versions.
|
||||||
|
*/
|
||||||
async isDirectory(path: string): Promise<boolean> {
|
async isDirectory(path: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await this.lstat(path + "/");
|
await this.lstat(path + "/");
|
||||||
|
|
|
@ -305,8 +305,13 @@ export class AdbPacketDispatcher implements Closeable {
|
||||||
// It's possible that we haven't received all `CLSE` confirm packets,
|
// It's possible that we haven't received all `CLSE` confirm packets,
|
||||||
// but it doesn't matter, the next connection can cope with them.
|
// but it doesn't matter, the next connection can cope with them.
|
||||||
this.#closed = true;
|
this.#closed = true;
|
||||||
|
|
||||||
this.#readAbortController.abort();
|
this.#readAbortController.abort();
|
||||||
|
if (this.options.preserveConnection ?? false) {
|
||||||
this.#writer.releaseLock();
|
this.#writer.releaseLock();
|
||||||
|
} else {
|
||||||
|
await this.#writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
// `pipe().then()` will call `dispose`
|
// `pipe().then()` will call `dispose`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue