-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(command cp'): key should be correct.
- Loading branch information
1 parent
8502b6d
commit 79acb12
Showing
4 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import * as path from "https://deno.land/[email protected]/path/mod.ts"; | ||
import * as fs from "https://deno.land/[email protected]/node/fs.ts"; | ||
import { walk } from "https://deno.land/[email protected]/fs/walk.ts"; | ||
import { tty } from "https://deno.land/x/[email protected]/ansi/tty.ts"; | ||
import { ansi } from "https://deno.land/x/[email protected]/ansi/ansi.ts"; | ||
import * as progress from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Config } from "../../core/main/Config.ts"; | ||
import { File } from "../../core/main/File.ts" | ||
import { IFile } from "../../core/interfaces/IFile.ts"; | ||
|
||
const bars = new progress.MultiProgressBar({ | ||
title: "Uploading files", | ||
display: "[:bar] :text :percent :time :completed/:total" | ||
display: `[:bar] :text :percent :time :completed/:total${ansi.eraseLineEnd.toString()}` | ||
}); | ||
|
||
export default async function upload(config: Config, paths: Array<string>, options: any){ | ||
|
@@ -41,23 +43,33 @@ export default async function upload(config: Config, paths: Array<string>, optio | |
for await (const entry of walk(fullpath, { maxDepth: options.recursive ? Infinity : 1 })){ | ||
if(entry.isFile){ | ||
files.push({ | ||
key: path.posix.join(dogePath, path.posix.normalize(entry.path).replace(path.posix.normalize(fullpath), "").replace("\\", "/")).replace("\\", "/"), | ||
key: path.posix.normalize(path.join(dogePath, path.posix.normalize(entry.path).replace(path.posix.normalize(fullpath), ""))).replaceAll("\\", "/"), | ||
local: entry.path | ||
} as IFile); | ||
} | ||
} | ||
|
||
files = file.filterFilesLocal(files, options.include, options.exclude); | ||
}else{ | ||
throw new Error(`${fullpath} rather be a directory or a file to be upload.`); | ||
} | ||
if(options.sync){ | ||
files = await file.syncFilter(files, options.signUrl === true); | ||
console.log(`Sync Hashing...${ansi.eraseLineEnd.toString()}`); | ||
tty.cursorUp(1); | ||
files = await file.syncFilter(files, options.signUrl === true, (file: IFile) => { | ||
tty.eraseLine; | ||
console.log(`Hashing ${file.local}...${ansi.eraseLineEnd.toString()}`); | ||
tty.cursorUp(1); | ||
}); | ||
} | ||
|
||
return await file.uploadFiles(files, options.partSize, options.threadNum, uploading); | ||
} | ||
|
||
function uploading(file: string, index: number, total: number, complete: number){ | ||
if(complete === 100){ | ||
complete-=0.0001; // For the progress don't `end'. | ||
} | ||
bars.render([ | ||
{ completed: complete, total: 100, text: file }, | ||
{ completed: index, total: total, text: "Total" }, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters