diff --git a/nextcloud-upload/package-lock.json b/nextcloud-upload/package-lock.json index 6e6a7e6..feb25ee 100644 --- a/nextcloud-upload/package-lock.json +++ b/nextcloud-upload/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "glob": "^10.3.1", - "nextcloud-chunk-file-upload": "^1.1.1", + "glob": "^10.3.10", + "nextcloud-chunk-file-upload": "^1.2.3", "xml2json": "^0.12.0" } }, @@ -135,9 +135,9 @@ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", "funding": [ { "type": "individual", @@ -169,18 +169,18 @@ } }, "node_modules/glob": { - "version": "10.3.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.3.tgz", - "integrity": "sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw==", + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^2.0.3", + "jackspeak": "^2.3.5", "minimatch": "^9.0.1", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", "path-scurry": "^1.10.1" }, "bin": { - "glob": "dist/cjs/src/bin.js" + "glob": "dist/esm/bin.mjs" }, "engines": { "node": ">=16 || 14 >=14.17" @@ -223,9 +223,9 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/jackspeak": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.2.1.tgz", - "integrity": "sha512-MXbxovZ/Pm42f6cDIDkl3xpwv1AGwObKwfmjs2nQePiy85tP3fatofl3FC1aBsOtP/6fq5SbtgHwWcMsLP+bDw==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", "dependencies": { "@isaacs/cliui": "^8.0.2" }, @@ -263,9 +263,9 @@ } }, "node_modules/lru-cache": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.0.tgz", - "integrity": "sha512-svTf/fzsKHffP42sujkO/Rjs37BCIsQVRCeNYIm9WN8rgT7ffoUnRtZCqU+6BqcSBdv8gwJeTz8knJpgACeQMw==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.3.tgz", + "integrity": "sha512-B7gr+F6MkqB3uzINHXNctGieGsRTMwIBgxkp0yq/5BwcuDzD4A8wQpHQW6vDAm1uKSLQghmRdD9sKqf2vJ1cEg==", "engines": { "node": "14 || >=16.14" } @@ -285,22 +285,22 @@ } }, "node_modules/minipass": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.2.tgz", - "integrity": "sha512-eL79dXrE1q9dBbDCLg7xfn/vl7MS4F1gvJAgjJrQli/jbQWdUttuVawphqpffoIYfRdq78LHx6GP4bU/EQ2ATA==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", "engines": { "node": ">=16 || 14 >=14.17" } }, "node_modules/nan": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", - "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==" + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", + "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==" }, "node_modules/nextcloud-chunk-file-upload": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/nextcloud-chunk-file-upload/-/nextcloud-chunk-file-upload-1.2.0.tgz", - "integrity": "sha512-C0vyCi2WV7B6mfwsYnIpqbKqSFHZSs9KxRdGFik4ey9Zm9YBtMqYAOT1Pkm/+ZUg4N0TdMuvFcAr5GgYqWcRvQ==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/nextcloud-chunk-file-upload/-/nextcloud-chunk-file-upload-1.2.3.tgz", + "integrity": "sha512-82Wz011qxKvDha7z/PcP7moULn14HeKJV2PPRJdnOwWMqbSnbAhYp4pjXi2mQzdJlqKxV6n01uXSBxZSvMt3Iw==", "dependencies": { "axios": "^0.24.0" } @@ -339,9 +339,9 @@ } }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "engines": { "node": ">=6" } @@ -366,9 +366,9 @@ } }, "node_modules/signal-exit": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", - "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "engines": { "node": ">=14" }, diff --git a/nextcloud-upload/package.json b/nextcloud-upload/package.json index b4c36d0..74e23ee 100644 --- a/nextcloud-upload/package.json +++ b/nextcloud-upload/package.json @@ -9,8 +9,8 @@ "author": "", "license": "MIT", "dependencies": { - "glob": "^10.3.1", - "nextcloud-chunk-file-upload": "^1.1.1", + "glob": "^10.3.10", + "nextcloud-chunk-file-upload": "^1.2.3", "xml2json": "^0.12.0" } } diff --git a/nextcloud-upload/run.js b/nextcloud-upload/run.js index a48c198..bbc39d4 100644 --- a/nextcloud-upload/run.js +++ b/nextcloud-upload/run.js @@ -150,43 +150,10 @@ async function upload() { file = file.replaceAll("\\", "/"); let fileName = file.split("/").pop(); let dest = `${destEnv}/${flatten ? fileName : file}`; - - // we have to explicitly create any directories that don't exist yet - // (https://github.com/shiftpi/nextcloud-chunk-file-upload/issues/22) - let currDir = ""; - for (let dir of dest.split("/").slice(0, -1)) { - currDir += `${dir}/`; - try { - let response = await axios.request({ - method: 'mkcol', - url: `${basePath}/files/${userEnv}/${currDir}`, - auth: { - username: userEnv, - password: tokenEnv - }, - // 405 means the directory already exists - validateStatus: s => s == 201 || s == 405 - }); - if (response.status != 405) { - if (!quiet) - console.log(`Created directory ${dir}`); - - // add tags to directory too - if (tagIds) - await addTags(basePath, tagIds, dir, currDir); - } - - } catch (error) { - console.log(`Failed to create directory ${dir} (${error})`); - process.exit(1); - } - - } - // use lib to upload file if (!quiet) console.log(`Uploading ${fileName} to ${dest}`); - await upload.uploadFile(`${baseDir}/${file}`, dest, parseInt(chunkSizeEnv)).then(e => { + await upload.uploadFile(`${baseDir}/${file}`, dest, parseInt(chunkSizeEnv), 5, true).then(() => { if (!quiet) console.log(`Uploaded ${fileName} to ${dest}`); }).catch(e => {