Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 701f4d82 authored by Simon Chan's avatar Simon Chan
Browse files

feat(adb): separate `type` and `permission` in sync write options

for easier consumption

fixes #533
parent 65c4dea3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -710,7 +710,8 @@ class FileManagerState {
                                })
                            )
                        ),
                    mode: (LinuxFileType.File << 12) | 0o666,
                    type: LinuxFileType.File,
                    permission: 0o666,
                    mtime: file.lastModified / 1000,
                });

+8 −3
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@ export interface AdbSyncPushV1Options {
    socket: AdbSyncSocket;
    filename: string;
    file: ReadableStream<Consumable<Uint8Array>>;
    mode?: number;
    type: LinuxFileType;
    permission: number;
    mtime?: number;
    packetSize?: number;
}
@@ -71,12 +72,14 @@ export async function adbSyncPushV1({
    socket,
    filename,
    file,
    mode = (LinuxFileType.File << 12) | 0o666,
    type = LinuxFileType.File,
    permission = 0o666,
    mtime = (Date.now() / 1000) | 0,
    packetSize = ADB_SYNC_MAX_PACKET_SIZE,
}: AdbSyncPushV1Options) {
    const locked = await socket.lock();
    try {
        const mode = (type << 12) | permission;
        const pathAndMode = `${filename},${mode.toString()}`;
        await adbSyncWriteRequest(locked, AdbSyncRequestId.Send, pathAndMode);
        await pipeFile(locked, file, packetSize, mtime);
@@ -115,7 +118,8 @@ export async function adbSyncPushV2({
    socket,
    filename,
    file,
    mode = (LinuxFileType.File << 12) | 0o666,
    type = LinuxFileType.File,
    permission = 0o666,
    mtime = (Date.now() / 1000) | 0,
    packetSize = ADB_SYNC_MAX_PACKET_SIZE,
    dryRun = false,
@@ -124,6 +128,7 @@ export async function adbSyncPushV2({
    try {
        await adbSyncWriteRequest(locked, AdbSyncRequestId.SendV2, filename);

        const mode = (type << 12) | permission;
        let flags: AdbSyncSendV2Flags = AdbSyncSendV2Flags.None;
        if (dryRun) {
            flags |= AdbSyncSendV2Flags.DryRun;
+3 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import { adbSyncOpenDir } from "./list.js";
import { adbSyncPull } from "./pull.js";
import { adbSyncPush } from "./push.js";
import { AdbSyncSocket } from "./socket.js";
import type { LinuxFileType } from "./stat.js";
import { adbSyncLstat, adbSyncStat } from "./stat.js";

/**
@@ -32,7 +33,8 @@ export function dirname(path: string): string {
export interface AdbSyncWriteOptions {
    filename: string;
    file: ReadableStream<Consumable<Uint8Array>>;
    mode?: number;
    type: LinuxFileType;
    permission: number;
    mtime?: number;
    dryRun?: boolean;
}