"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_path_1 = require("node:path");
const Queue_1 = __importDefault(require("./Queue"));
const types_1 = require("../types");
const Local_1 = require("../Local");
class DownloadQueue extends Queue_1.default {
    constructor(connId, src, dest, filter, onState, onConflict, onError, onComplete) {
        super(connId, types_1.LocalFileSystemID, src, dest, filter, onState, onConflict, onComplete);
        this.onError = onError;
    }
    async transmit(fs, from, dirs, to) {
        if (this.stopped) {
            return;
        }
        const dest = (0, node_path_1.join)(to, ...dirs, from.name);
        await (0, Local_1.touch)(dest);
        try {
            await fs.get(from.path, dest);
        }
        catch (error) {
            this.onError(error);
        }
        this.sendState(from.size);
    }
}
exports.default = DownloadQueue;
