Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use stat instead of statSync #14

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ on:
branches:
- main
- master
- 1.x
pull_request:
branches:
- main
- master
- 1.x

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
push:
branches: [ master ]
branches: [ master, 1.x ]

jobs:
release:
Expand Down
5 changes: 3 additions & 2 deletions lib/object.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs');
const { stat } = require('fs/promises');
const is = require('is-type-of');
const copy = require('copy-to');
const path = require('path');
Expand Down Expand Up @@ -59,12 +60,12 @@ proto.put = async function put(name, file, options) {
if (Buffer.isBuffer(file)) {
content = file;
} else if (is.string(file)) {
const stats = fs.statSync(file);
const stats = await stat(file);
if (!stats.isFile()) {
throw new Error(`${file} is not file`);
}
options.mime = options.mime || mime.getType(path.extname(file));
options.contentLength = await this._getFileSize(file);
options.contentLength = stats.size;
const getStream = () => fs.createReadStream(file);
const putStreamStb = (objectName, makeStream, configOption) => {
return this.putStream(objectName, makeStream(), configOption);
Expand Down
Loading