Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions actions/rsync-cache/dist/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30797,7 +30797,6 @@ class Rsync {
this.ssh_dir = `${this.ssh_user}@${this.ssh_host}:${this.name}/${this.key}/`;

this._validate();
this._set_vars();
}

// Ensure all our settings look good.
Expand All @@ -30820,10 +30819,12 @@ class Rsync {
}

// Prepare some variables.
_set_vars() {
async _set_vars() {
const ssh_exe = await this._find_ssh();

// The SSH command line.
const ssh_command = [
"ssh",
ssh_exe,
"-i",
this.ssh_key_file,
"-p",
Expand All @@ -30849,12 +30850,31 @@ class Rsync {
];
}

// Try to find the path to SSH.
async _find_ssh() {
if (this.core.platform.isWindows) {
const base = "C:\\ProgramData\\chocolatey\\lib\\rsync\\tools";
const files = await this.fs.readdir(base, { recursive: true });

for (const file of files) {
if (file.endsWith("\\ssh.exe") || file.endsWith("/ssh.exe")) {
return `${base}\\${file}`;
}
}

throw new Error(`unable to find ssh.exe on Windows`);
} else {
return "ssh";
}
}

// Run rsync with extra arguments and return its exit code.
async run(additional_arguments = []) {
if (this.disabled) {
return 0;
}

await this._set_vars();
let exit_code = -1;

try {
Expand Down
2 changes: 1 addition & 1 deletion actions/rsync-cache/dist/commit.js.map

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions actions/rsync-cache/dist/restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -30797,7 +30797,6 @@ class Rsync {
this.ssh_dir = `${this.ssh_user}@${this.ssh_host}:${this.name}/${this.key}/`;

this._validate();
this._set_vars();
}

// Ensure all our settings look good.
Expand All @@ -30820,10 +30819,12 @@ class Rsync {
}

// Prepare some variables.
_set_vars() {
async _set_vars() {
const ssh_exe = await this._find_ssh();

// The SSH command line.
const ssh_command = [
"ssh",
ssh_exe,
"-i",
this.ssh_key_file,
"-p",
Expand All @@ -30849,12 +30850,31 @@ class Rsync {
];
}

// Try to find the path to SSH.
async _find_ssh() {
if (this.core.platform.isWindows) {
const base = "C:\\ProgramData\\chocolatey\\lib\\rsync\\tools";
const files = await this.fs.readdir(base, { recursive: true });

for (const file of files) {
if (file.endsWith("\\ssh.exe") || file.endsWith("/ssh.exe")) {
return `${base}\\${file}`;
}
}

throw new Error(`unable to find ssh.exe on Windows`);
} else {
return "ssh";
}
}

// Run rsync with extra arguments and return its exit code.
async run(additional_arguments = []) {
if (this.disabled) {
return 0;
}

await this._set_vars();
let exit_code = -1;

try {
Expand Down
2 changes: 1 addition & 1 deletion actions/rsync-cache/dist/restore.js.map

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions actions/rsync-cache/src/rsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default class Rsync {
this.ssh_dir = `${this.ssh_user}@${this.ssh_host}:${this.name}/${this.key}/`;

this._validate();
this._set_vars();
}

// Ensure all our settings look good.
Expand All @@ -66,10 +65,12 @@ export default class Rsync {
}

// Prepare some variables.
_set_vars() {
async _set_vars() {
const ssh_exe = await this._find_ssh();

// The SSH command line.
const ssh_command = [
"ssh",
ssh_exe,
"-i",
this.ssh_key_file,
"-p",
Expand All @@ -95,12 +96,31 @@ export default class Rsync {
];
}

// Try to find the path to SSH.
async _find_ssh() {
if (this.core.platform.isWindows) {
const base = "C:\\ProgramData\\chocolatey\\lib\\rsync\\tools";
const files = await this.fs.readdir(base, { recursive: true });

for (const file of files) {
if (file.endsWith("\\ssh.exe") || file.endsWith("/ssh.exe")) {
return `${base}\\${file}`;
}
}

throw new Error(`unable to find ssh.exe on Windows`);
} else {
return "ssh";
}
}

// Run rsync with extra arguments and return its exit code.
async run(additional_arguments = []) {
if (this.disabled) {
return 0;
}

await this._set_vars();
let exit_code = -1;

try {
Expand Down
22 changes: 22 additions & 0 deletions actions/rsync-cache/test/rsync_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Deps {
constructor(inputs) {
this.inputs = inputs;
this.notices = [];
this.platform = { isWindows: false };
}

getInput(key, options = {}) {
Expand Down Expand Up @@ -88,6 +89,7 @@ class Deps {
this.files = new Map();
this.modes = new Map();
this.unlinked = [];
this.readdir_files = [];
}

async writeFile(name, content, encoding) {
Expand All @@ -101,6 +103,10 @@ class Deps {
async unlink(file) {
this.unlinked.push(file);
}

async readdir() {
return this.readdir_files;
}
})();

return new Rsync({
Expand Down Expand Up @@ -198,6 +204,22 @@ test("can push the cache", async () => {
assert(deps.core.notices.length == 0);
});

test("windows can find ssh.exe", async () => {
let deps = new Deps();
let rsync = deps.rsync();

deps.core.platform.isWindows = true;
deps.fs.readdir_files = ["fake\\foo", "bin\\ssh.exe"];

await rsync.push();

const args = deps.exec.commands.at(-1).at(1);
assert.equal("-e", args.at(0));

const ssh_command = args.at(1).split(" ").at(0);
assert(ssh_command.endsWith("bin\\ssh.exe"));
});

test("disabled on missing ssh key", async () => {
for (const key of [null, "", " "]) {
let deps = new Deps();
Expand Down