/* This file is part of »mimir«. Copyright 2025 kcf »mimir« is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. »mimir« is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with »mimir«. If not, see . */ namespace _mimir.transfer.borg { /** */ export type type_encryption = ( { kind : "none"; data : { }; } | { kind : "repokey"; data : { passphrase : string; }; } /* | { kind : "keyfile"; data : { path : string; passphrase : string; }; } */ ); /** */ export type type_parameters = { repository : string; compression : string; encryption : type_encryption; pruning : { keep_within : string; keep_weekly : int; keep_yearly : int; } }; /** */ export function execute( parameters : type_parameters, name : string, stamp : string, directory : string ) : Array { const result : Array = []; result.push( _mimir.helpers.borg.create( parameters.repository, lib_plankton.string.coin( "{{stamp}}-{{name}}", { "name": name, "stamp": stamp, } ), [directory], { "passphrase": ( (parameters.encryption.kind === "repokey") ? parameters.encryption.data.passphrase : null ), "compression": parameters.compression, } ) ); result.push( _mimir.helpers.borg.prune( parameters.repository, parameters.pruning.keep_within, { "keep_weekly": parameters.pruning.keep_weekly, "keep_yearly": parameters.pruning.keep_yearly, } ) ); return result; } /** */ export function logic( parameters : type_parameters ) : _mimir.transfer.type_logic { return { "execute": (name, stamp, directory) => execute(parameters, name, stamp, directory), }; } }