Skip to content

Commit

Permalink
fix: sftp error when dir already exists (#4024)
Browse files Browse the repository at this point in the history
when the dir exists, sftp.mkdir() would raise an error and ends the for loop.
  • Loading branch information
Rainshaw authored Sep 15, 2021
1 parent 5450597 commit 1dc9742
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/modules/storage/sftp/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ module.exports = {
const folderPaths = _.dropRight(filePath.split('/'))
for (let i = 1; i <= folderPaths.length; i++) {
const folderSection = _.take(folderPaths, i).join('/')
await this.sftp.mkdir(path.posix.join(this.config.basePath, folderSection))
const folderDir = path.posix.join(this.config.basePath, folderSection)
try {
await this.sftp.readdir(folderDir)
} catch (err) {
await this.sftp.mkdir(folderDir)
}
}
} catch (err) {}
}
Expand Down

0 comments on commit 1dc9742

Please sign in to comment.