Browse Source
fix: sftp error when dir already exists (#4024)
when the dir exists, sftp.mkdir() would raise an error and ends the for loop.
pull/4480/head
Rainshaw
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
1 deletions
-
server/modules/storage/sftp/storage.js
|
@ -155,7 +155,12 @@ module.exports = { |
|
|
const folderPaths = _.dropRight(filePath.split('/')) |
|
|
const folderPaths = _.dropRight(filePath.split('/')) |
|
|
for (let i = 1; i <= folderPaths.length; i++) { |
|
|
for (let i = 1; i <= folderPaths.length; i++) { |
|
|
const folderSection = _.take(folderPaths, i).join('/') |
|
|
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) {} |
|
|
} catch (err) {} |
|
|
} |
|
|
} |
|
|