fix: the invalid file path check.

This commit is contained in:
Yufan Sheng 2024-12-03 17:01:32 +08:00
parent ed9d6c7c89
commit 7036d92284
No known key found for this signature in database
GPG Key ID: 980439DFE585D1D8
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "astro-uploader",
"version": "1.2.1",
"version": "1.2.2",
"description": "A uploader for uploading the Astro generated files through the S3 API.",
"keywords": ["Astro", "S3", "withastro", "opendal"],
"bugs": {

View File

@ -217,9 +217,9 @@ const uploadFile = async (
keep: boolean;
override: boolean;
},
root: string,
buildPath: string,
) => {
const filePath = current.path;
const filePath = path.join(buildPath, current.path);
const fileStats = fs.statSync(filePath);
const isFile = !fileStats.isDirectory();
const uploadAction = async (key: string) => {
@ -229,7 +229,7 @@ const uploadFile = async (
};
if (isFile) {
const key = normalizePath(path.join(root, current.path));
const key = normalizePath(current.path);
if (await uploader.isExist(key, fileStats.size, current.override)) {
logger.info(`${key} exists on backend, skip.`);
} else {
@ -248,7 +248,7 @@ const uploadFile = async (
const nextFilePath = path.join(current.path, next);
if (current.recursive || !fs.statSync(nextFilePath).isDirectory()) {
await uploadFile(uploader, logger, { ...current, path: nextFilePath }, root);
await uploadFile(uploader, logger, { ...current, path: nextFilePath }, buildPath);
}
}
}