Skip to content

Commit

Permalink
fix: use stat instead of statSync (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Sep 18, 2023
1 parent e5d14dd commit 8380b87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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

0 comments on commit 8380b87

Please sign in to comment.