Skip to content

Commit

Permalink
Bugfix: Fix how we handle paths when uploading (#4410)
Browse files Browse the repository at this point in the history
* Bugfix: Fix how we handle paths when uploading

* lint
soulgalore authored Jan 23, 2025
1 parent 62c2613 commit 05559a1
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/gcs/index.js
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ async function uploadLatestFiles(dir, gcsOptions, prefix) {
}

async function upload(dir, gcsOptions, prefix) {
const files = await recursiveReaddir(dir, true);
const files = await recursiveReaddir(dir);
const promises = [];

const storage = new Storage({
2 changes: 1 addition & 1 deletion lib/plugins/s3/index.js
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ export default class S3Plugin extends SitespeedioPlugin {
);

try {
const files = await recursiveReaddir(baseDir, true);
const files = await recursiveReaddir(baseDir);
const tasks = files.map(file => async () => {
return uploadFile(
file,
8 changes: 4 additions & 4 deletions lib/support/fileUtil.js
Original file line number Diff line number Diff line change
@@ -2,18 +2,18 @@ import { readdir } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import path from 'node:path';

export async function recursiveReaddir(dir, ignoreDirectories = false) {
export async function recursiveReaddir(dir, skipDirectories = false) {
const results = [];
const entries = await readdir(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);

if (entry.isDirectory()) {
if (!ignoreDirectories) {
results.push(fullPath);
if (skipDirectories) {
continue;
}
const subPaths = await recursiveReaddir(fullPath, ignoreDirectories);
const subPaths = await recursiveReaddir(fullPath, skipDirectories);
results.push(...subPaths);
} else {
results.push(fullPath);

0 comments on commit 05559a1

Please sign in to comment.