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

refactor: new use nodejs fs api #1152

Merged
merged 1 commit into from
May 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 1 addition & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"json-stream": "^1.0.0",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
"mkdirp": "^0.5.6",
"query-string": "^7.1.3",
"through2": "^4.0.2",
"web-encoding": "^1.1.5",
Expand Down
3 changes: 3 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ export class CopySourceOptions {
}
}

/**
* @deprecated use nodejs fs module
*/
export function removeDirAndFiles(dirPath: string, removeSelf = true) {
if (removeSelf) {
return fs.rmSync(dirPath, { recursive: true, force: true })
Expand Down
5 changes: 2 additions & 3 deletions src/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import * as Stream from 'node:stream'
import async from 'async'
import BlockStream2 from 'block-stream2'
import _ from 'lodash'
import mkdirp from 'mkdirp'
import * as querystring from 'query-string'
import { TextEncoder } from 'web-encoding'
import Xml from 'xml'
Expand Down Expand Up @@ -997,9 +996,9 @@ export class Client {
(result, cb) => {
objStat = result
// Create any missing top level directories.
mkdirp(path.dirname(filePath), cb)
fs.mkdir(path.dirname(filePath), { recursive: true }, (err) => cb(err))
},
(ignore, cb) => {
(cb) => {
partFile = `${filePath}.${objStat.etag}.part.minio`
fs.stat(partFile, (e, stats) => {
var offset = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/functional-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import superagent from 'superagent'
import * as uuid from 'uuid'

import { AssumeRoleProvider } from '../../src/AssumeRoleProvider.ts'
import { CopyDestinationOptions, CopySourceOptions, DEFAULT_REGION, removeDirAndFiles } from '../../src/helpers.ts'
import { CopyDestinationOptions, CopySourceOptions, DEFAULT_REGION } from '../../src/helpers.ts'
import { getVersionId } from '../../src/internal/helper.ts'
import * as minio from '../../src/minio.js'

Expand Down Expand Up @@ -4136,7 +4136,7 @@ describe('functional tests', function () {

step('Clean up temp directory part files', (done) => {
if (isSplitSuccess) {
removeDirAndFiles(tmpSubDir)
fs.rmdirSync(tmpSubDir)
}
done()
})
Expand Down