mirror of
https://github.com/trympet/nextcloud-artifacts-action.git
synced 2025-04-25 20:36:08 +02:00
test
This commit is contained in:
parent
51f5e63425
commit
ab2bf8a4ac
1453
dist/index.js
vendored
1453
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -153,7 +153,7 @@ export class NextcloudClient {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private async upload(file: string) {
|
private async upload(file: string): Promise<string> {
|
||||||
const remoteFileDir = `/artifacts/${this.guid}`;
|
const remoteFileDir = `/artifacts/${this.guid}`;
|
||||||
core.info("Checking directory...");
|
core.info("Checking directory...");
|
||||||
if (!(await this.davClient.exists(remoteFileDir))) {
|
if (!(await this.davClient.exists(remoteFileDir))) {
|
||||||
@ -164,6 +164,13 @@ export class NextcloudClient {
|
|||||||
const remoteFilePath = `${remoteFileDir}/${this.artifact}.zip`;
|
const remoteFilePath = `${remoteFileDir}/${this.artifact}.zip`;
|
||||||
core.info(`Transferring file... (${file})`);
|
core.info(`Transferring file... (${file})`);
|
||||||
|
|
||||||
|
await this.transferFile(remoteFilePath, file);
|
||||||
|
|
||||||
|
core.info("finish");
|
||||||
|
return remoteFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private transferFile(remoteFilePath: string, file: string): Promise<[void, void]> {
|
||||||
const remoteStream = this.davClient.createWriteStream(remoteFilePath);
|
const remoteStream = this.davClient.createWriteStream(remoteFilePath);
|
||||||
const remoteStreamPromise = new Promise<void>((resolve, reject) => {
|
const remoteStreamPromise = new Promise<void>((resolve, reject) => {
|
||||||
remoteStream.on('error', () => reject("Failed to upload file"))
|
remoteStream.on('error', () => reject("Failed to upload file"))
|
||||||
@ -175,13 +182,10 @@ export class NextcloudClient {
|
|||||||
fileStream.on('error', () => reject("Failed to read file"))
|
fileStream.on('error', () => reject("Failed to read file"))
|
||||||
.on('end', () => resolve());
|
.on('end', () => resolve());
|
||||||
});
|
});
|
||||||
|
|
||||||
fileStream.pipe(remoteStream);
|
fileStream.pipe(remoteStream);
|
||||||
|
|
||||||
await Promise.all([remoteStreamPromise, fileStreamPromise]);
|
return Promise.all([remoteStreamPromise, fileStreamPromise]);
|
||||||
|
|
||||||
core.info("finish");
|
|
||||||
return remoteFilePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async shareFile(remoteFilePath: string) {
|
private async shareFile(remoteFilePath: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user