patch downloading and uploading

This commit is contained in:
2025-05-13 20:47:49 -07:00
parent cb62bfd3e0
commit 3c08ababe7
2 changed files with 19 additions and 3 deletions

View File

@ -263,9 +263,19 @@ const uploadToSFTP = async () => {
try {
await sftp.connect(connectOptions);
const remoteFiles = await sftp.list(remote);
for (const file of remoteFiles) {
if (file.name.endsWith(".jar") && files.includes(file.name)) {
const remoteFilePath = path.posix.join(remote, file.name);
console.log(`🗑️ Deleting remote file: ${remoteFilePath}`);
await sftp.delete(remoteFilePath);
}
}
// 🚀 Upload new files
for (const file of files) {
const local = path.join(DOWNLOAD_PATH, file);
const remoteFile = path.join(remote, file).replace(/\\/g, "/");
const remoteFile = path.posix.join(remote, file);
console.log(`🚀 Uploading ${file}${remoteFile}`);
await sftp.put(local, remoteFile);
}
@ -279,6 +289,12 @@ const uploadToSFTP = async () => {
// --- Main ---
(async () => {
ensureDir(DOWNLOAD_PATH);
const existingFiles = fs.readdirSync(DOWNLOAD_PATH).filter(f => f.endsWith(".jar"));
for (const file of existingFiles) {
const filePath = path.join(DOWNLOAD_PATH, file);
fs.unlinkSync(filePath);
console.log(`🗑️ Deleted local file: ${file}`);
}
for (const url of config.urls) {
console.log(`\n📥 ${url}`);

View File

@ -1,13 +1,13 @@
{
"name": "download-plugs",
"version": "1.0.0",
"version": "1.0.4",
"main": "index.js",
"scripts": {
"run": "node index.js"
},
"keywords": [],
"author": "Sophia Atkinson",
"license": "MIT?",
"license": "MIT",
"description": "",
"dependencies": {
"axios": "^1.9.0",