Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
khattori committed Oct 26, 2024
1 parent ce41ab9 commit 14cb24f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/commands/put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export default class Put extends Command {
const cwd = await checkCwd(this.conf, flags.cwd)
let dest = path.normalize(path.join(cwd, flags.dest || ''))
const sources = await this.checkSources(argv as string[], path.resolve('.'))

if (sources.length === 0) {
return
}

let target: KeClient.ObjectResponse | null | string = await KeClient.get(this.conf, dest)

if (argv.length === 1) {
Expand All @@ -81,7 +86,10 @@ export default class Put extends Command {

// dest 配下にsources をコピー
await Promise.all(
sources.map((src) => this.putObject(dest, src, src.name, flags))
sources.map(async (src) => {
const target = await KeClient.get(this.conf, path.join(dest, src.name)) || src.name
await this.putObject(dest, src, target, flags)
})
)
}
}
Expand Down Expand Up @@ -116,6 +124,7 @@ export default class Put extends Command {

private async putObject(dest: string, source: SourceDesc, target: KeClient.ObjectResponse | string, options: PutOptions) {
let destDir = null

if (target instanceof Object) {
if (target.type_object === DIRECTORY_TYPE && source.type === 'dir') {
destDir = target.abspath
Expand Down Expand Up @@ -175,7 +184,7 @@ export default class Put extends Command {

await Promise.all(
sources.map(async (src) => {
target = await KeClient.get(this.conf, path.join(destDir, src.name)) || src.name
const target = await KeClient.get(this.conf, path.join(destDir, src.name)) || src.name
await this.putObject(destDir, src, target, options)
})
)
Expand Down

0 comments on commit 14cb24f

Please sign in to comment.