mirror of
https://github.com/rexlManu/pterodactyl-upload-action.git
synced 2025-02-03 21:46:40 -05:00
Refactor: Convert decompress to decompress-target
This commit is contained in:
parent
f08d518ad6
commit
72e83f2386
1 changed files with 10 additions and 5 deletions
15
src/index.js
15
src/index.js
|
@ -10,7 +10,7 @@ async function main() {
|
|||
const settings = await getSettings();
|
||||
configureAxios(settings.panelHost, settings.apiKey, settings.proxy);
|
||||
|
||||
const { serverIds, sourceListPath, targetPath, restart, targets, decompress } =
|
||||
const { serverIds, sourceListPath, targetPath, restart, targets, decompressTarget } =
|
||||
settings;
|
||||
|
||||
for (const serverId of serverIds) {
|
||||
|
@ -21,7 +21,7 @@ async function main() {
|
|||
|
||||
await uploadFile(serverId, targetFile, buffer);
|
||||
|
||||
if (decompress && decompress === source) {
|
||||
if (decompressTarget && isArchiveFile(targetFile)) {
|
||||
await decompressFile(serverId, targetFile);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ async function main() {
|
|||
|
||||
await uploadFile(serverId, targetFile, buffer);
|
||||
|
||||
if (decompress && decompress === source) {
|
||||
if (decompressTarget && isArchiveFile(targetFile)) {
|
||||
await decompressFile(serverId, targetFile);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ async function getSettings() {
|
|||
const apiKey = getInput("api-key", { required: true });
|
||||
const restart = getInput("restart") == "true";
|
||||
const proxy = getInput("proxy");
|
||||
const decompress = getInput("decompress");
|
||||
const decompressTarget = getInput("decompress-target") == "true";
|
||||
|
||||
let sourcePath = getInput("source");
|
||||
let sourceListPath = getMultilineInput("sources");
|
||||
|
@ -116,7 +116,7 @@ async function getSettings() {
|
|||
targetPath,
|
||||
serverIds,
|
||||
targets,
|
||||
decompress,
|
||||
decompressTarget,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,11 @@ async function validateSourceFile(source) {
|
|||
}
|
||||
}
|
||||
|
||||
function isArchiveFile(fileName) {
|
||||
const ext = path.extname(fileName).toLowerCase();
|
||||
return ['.zip', '.tar', '.tar.gz', '.tgz', '.rar'].includes(ext);
|
||||
}
|
||||
|
||||
function getTargetFile(targetPath, source) {
|
||||
return targetPath.endsWith("/")
|
||||
? path.join(targetPath, path.basename(source))
|
||||
|
|
Loading…
Reference in a new issue