Add cast syntax check logic
-- TypeA for both cast and copy targetURL check shouldn't fail it it doesn't exist such is a common occurrence of not having a target, instead we verify if it exists is it a directory? -- Rename all 'directory' references to folder
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ $ mc --help
|
||||
* If you have additional dependencies for ``mc``, ``mc`` manages its depedencies using [godep](https://github.com/tools/godep)
|
||||
- Run `go get foo/bar`
|
||||
- Edit your code to import foo/bar
|
||||
- Run `make save` from top-level directory (or `godep restore && godep save ./...`).
|
||||
- Run `make save` from top-level folder (or `godep restore && godep save ./...`).
|
||||
|
||||
* When you're ready to create a pull request, be sure to:
|
||||
- Have test cases for the new code. If you have questions about how to do it, please ask in your pull request.
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ func (l *logger) String() string {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Handling of temporary files and directories.
|
||||
// Handling of temporary files and folders.
|
||||
|
||||
type tempDir struct {
|
||||
sync.Mutex
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ EXAMPLES:
|
||||
4. Cast a bucket from aliased Amazon S3 object storage to multiple folders on Windows.
|
||||
$ mc {{.Name}} s3:documents/2014/... C:\backup\2014 C:\shared\volume\backup\2014
|
||||
|
||||
5. Cast a local directory of non english character recursively to Amazon s3 object storage and Minio object storage.
|
||||
5. Cast a local folder of non english character recursively to Amazon s3 object storage and Minio object storage.
|
||||
$ mc {{.Name}} 本語/... s3:mylocaldocuments play:backup
|
||||
|
||||
`,
|
||||
@@ -269,7 +269,7 @@ func runCastCmd(ctx *cli.Context) {
|
||||
session.Header.RootPath, err = os.Getwd()
|
||||
if err != nil {
|
||||
session.Close()
|
||||
console.Fatalf("Unable to get current working directory. %s\n", err)
|
||||
console.Fatalf("Unable to get current working folder. %s\n", err)
|
||||
}
|
||||
|
||||
// extract URLs.
|
||||
|
||||
+76
-22
@@ -39,7 +39,6 @@ const (
|
||||
castURLsTypeA
|
||||
castURLsTypeB
|
||||
castURLsTypeC
|
||||
castURLsTypeD
|
||||
)
|
||||
|
||||
// NOTE: All the parse rules should reduced to A: Cast(Source, []Target).
|
||||
@@ -68,7 +67,7 @@ func checkCastSyntax(ctx *cli.Context) {
|
||||
tgtURLs := URLs[1:]
|
||||
|
||||
/****** Generic rules *******/
|
||||
// Source cannot be a directory (except when recursive)
|
||||
// Source cannot be a folder (except when recursive)
|
||||
if !isURLRecursive(srcURL) {
|
||||
_, srcContent, err := url2Stat(srcURL)
|
||||
// Source exist?.
|
||||
@@ -77,7 +76,7 @@ func checkCastSyntax(ctx *cli.Context) {
|
||||
}
|
||||
if !srcContent.Type.IsRegular() {
|
||||
if srcContent.Type.IsDir() {
|
||||
console.Fatalf("Source ‘%s’ is a directory. Please use ‘%s...’ to recursively copy this directory and its contents.\n", srcURL, srcURL)
|
||||
console.Fatalf("Source ‘%s’ is a folder. Please use ‘%s...’ to recursively copy this folder and its contents.\n", srcURL, srcURL)
|
||||
}
|
||||
console.Fatalf("Source ‘%s’ is not a regular file.\n", srcURL)
|
||||
}
|
||||
@@ -90,27 +89,82 @@ func checkCastSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
switch guessCastURLType(srcURL, tgtURLs) {
|
||||
case castURLsTypeA: // Source is already a regular file.
|
||||
//
|
||||
case castURLsTypeB: // Source is already a regular file.
|
||||
//
|
||||
case castURLsTypeC:
|
||||
srcURL = stripRecursiveURL(srcURL)
|
||||
_, srcContent, err := url2Stat(srcURL)
|
||||
// Source exist?.
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
|
||||
if srcContent.Type.IsRegular() { // Ellipses is supported only for directories.
|
||||
console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
|
||||
case castURLsTypeA: // File -> File.
|
||||
checkCastSyntaxTypeA(srcURL, tgtURLs)
|
||||
case castURLsTypeB: // File -> Folder.
|
||||
checkCastSyntaxTypeB(srcURL, tgtURLs)
|
||||
case castURLsTypeC: // Folder -> Folder.
|
||||
checkCastSyntaxTypeC(srcURL, tgtURLs)
|
||||
default:
|
||||
console.Fatalln("Invalid arguments. Unable to determine how to cast. Please report this issue at https://github.com/minio/mc/issues")
|
||||
}
|
||||
}
|
||||
|
||||
func checkCastSyntaxTypeA(srcURL string, tgtURLs []string) {
|
||||
if len(tgtURLs) == 0 && tgtURLs == nil {
|
||||
console.Fatalf("Invalid number of target arguments to cast command. %s\n", NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
_, srcContent, err := url2Stat(srcURL)
|
||||
// Source exist?.
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if srcContent.Type.IsDir() {
|
||||
console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to cast this folder and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
if !srcContent.Type.IsRegular() {
|
||||
console.Fatalf("Source ‘%s’ is not a file. %s\n", srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
for _, tgtURL := range tgtURLs {
|
||||
_, tgtContent, err := url2Stat(tgtURL)
|
||||
// Target exist?.
|
||||
if err == nil {
|
||||
if !tgtContent.Type.IsRegular() {
|
||||
console.Fatalf("Target ‘%s’ is not a file. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkCastSyntaxTypeB(srcURL string, tgtURLs []string) {
|
||||
if len(tgtURLs) == 0 && tgtURLs == nil {
|
||||
console.Fatalf("Invalid number of target arguments to cast command. %s\n", NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
_, srcContent, err := url2Stat(srcURL)
|
||||
// Source exist?.
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if srcContent.Type.IsDir() {
|
||||
console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to cast this folder and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
if !srcContent.Type.IsRegular() {
|
||||
console.Fatalf("Source ‘%s’ is not a file. %s\n", srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
// targetURL can be folder or file, internally TypeB calls TypeA if it finds a file
|
||||
}
|
||||
|
||||
func checkCastSyntaxTypeC(srcURL string, tgtURLs []string) {
|
||||
if len(tgtURLs) == 0 && tgtURLs == nil {
|
||||
console.Fatalf("Invalid number of target arguments to cast command. %s\n", NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
srcURL = stripRecursiveURL(srcURL)
|
||||
_, srcContent, err := url2Stat(srcURL)
|
||||
// Source exist?.
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
|
||||
if srcContent.Type.IsRegular() { // Ellipses is supported only for folders.
|
||||
console.Fatalf("Source ‘%s’ is not a folder. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
for _, tgtURL := range tgtURLs {
|
||||
if !isTargetURLDir(tgtURL) {
|
||||
console.Fatalf("One of the target ‘%s’ is not a folder. cannot have mixtures of directories and files while copying directories. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// guessCastURLType guesses the type of URL. This approach all allows prepareURL
|
||||
// functions to accurately report failure causes.
|
||||
func guessCastURLType(sourceURL string, targetURLs []string) castURLsType {
|
||||
@@ -190,7 +244,7 @@ func prepareSingleCastURLsTypeB(sourceURL string, targetURL string) castURLs {
|
||||
return prepareSingleCastURLsTypeA(sourceURL, targetURL)
|
||||
}
|
||||
|
||||
// Source is a file, target is a directory and exists.
|
||||
// Source is a file, target is a folder and exists.
|
||||
sourceURLParse, err := client.Parse(sourceURL)
|
||||
if err != nil {
|
||||
return castURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
|
||||
@@ -229,7 +283,7 @@ func prepareCastURLsTypeC(sourceURL string, targetURLs []string) <-chan castURLs
|
||||
castURLsCh <- castURLs{Error: NewIodine(iodine.New(errSourceNotRecursive{URL: sourceURL}, nil))}
|
||||
return
|
||||
}
|
||||
// add `/` after trimming off `...` to emulate directories
|
||||
// add `/` after trimming off `...` to emulate folders
|
||||
sourceURL = stripRecursiveURL(sourceURL)
|
||||
sourceClient, sourceContent, err := url2Stat(sourceURL)
|
||||
// Source exist?
|
||||
@@ -255,7 +309,7 @@ func prepareCastURLsTypeC(sourceURL string, targetURLs []string) <-chan castURLs
|
||||
// Source is not a regular file. Skip it for cast.
|
||||
continue
|
||||
}
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a directory and exists.
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a folder and exists.
|
||||
sourceURLParse, err := client.Parse(sourceURL)
|
||||
if err != nil {
|
||||
castURLsCh <- castURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import (
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
// Check if the target URL represents directory. It may or may not exist yet.
|
||||
// Check if the target URL represents folder. It may or may not exist yet.
|
||||
func isTargetURLDir(targetURL string) bool {
|
||||
targetURLParse, err := client.Parse(targetURL)
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -272,7 +272,7 @@ func runCopyCmd(ctx *cli.Context) {
|
||||
session.Header.RootPath, err = os.Getwd()
|
||||
if err != nil {
|
||||
session.Close()
|
||||
console.Fatalf("Unable to get current working directory. %s\n", err)
|
||||
console.Fatalf("Unable to get current working folder. %s\n", err)
|
||||
}
|
||||
|
||||
// extract URLs.
|
||||
|
||||
@@ -81,11 +81,11 @@ func checkCopySyntax(ctx *cli.Context) {
|
||||
switch guessCopyURLType(srcURLs, tgtURL) {
|
||||
case copyURLsTypeA: // File -> File.
|
||||
checkCopySyntaxTypeA(srcURLs, tgtURL)
|
||||
case copyURLsTypeB: // File -> Directory.
|
||||
case copyURLsTypeB: // File -> Folder.
|
||||
checkCopySyntaxTypeB(srcURLs, tgtURL)
|
||||
case copyURLsTypeC: // Directory... -> Directory.
|
||||
case copyURLsTypeC: // Folder... -> Folder.
|
||||
checkCopySyntaxTypeC(srcURLs, tgtURL)
|
||||
case copyURLsTypeD: // File | Directory... -> Directory.
|
||||
case copyURLsTypeD: // File | Folder... -> Folder.
|
||||
checkCopySyntaxTypeD(srcURLs, tgtURL)
|
||||
default:
|
||||
console.Fatalln("Invalid arguments. Unable to determine how to copy. Please report this issue at https://github.com/minio/mc/issues")
|
||||
@@ -103,17 +103,19 @@ func checkCopySyntaxTypeA(srcURLs []string, tgtURL string) {
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if srcContent.Type.IsDir() {
|
||||
console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to copy this folder and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
if !srcContent.Type.IsRegular() {
|
||||
console.Fatalf("Source ‘%s’ is not a file. %s\n", srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
|
||||
_, tgtContent, err := url2Stat(tgtURL)
|
||||
// Target exist?.
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat target ‘%s’. %s\n", tgtURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if !tgtContent.Type.IsRegular() {
|
||||
console.Fatalf("Target ‘%s’ is not a file. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
if err == nil {
|
||||
if !tgtContent.Type.IsRegular() {
|
||||
console.Fatalf("Target ‘%s’ is not a file. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +131,7 @@ func checkCopySyntaxTypeB(srcURLs []string, tgtURL string) {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if srcContent.Type.IsDir() {
|
||||
console.Fatalf("Source ‘%s’ is a directory. Use ‘%s...’ argument to copy this directory and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to copy this folder and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
if !srcContent.Type.IsRegular() {
|
||||
console.Fatalf("Source ‘%s’ is not a file. %s\n", srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
@@ -137,11 +139,10 @@ func checkCopySyntaxTypeB(srcURLs []string, tgtURL string) {
|
||||
|
||||
_, tgtContent, err := url2Stat(tgtURL)
|
||||
// Target exist?.
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat target ‘%s’. %s\n", tgtURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if !tgtContent.Type.IsDir() {
|
||||
console.Fatalf("Target ‘%s’ is not a directory. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
if err == nil {
|
||||
if !tgtContent.Type.IsDir() {
|
||||
console.Fatalf("Target ‘%s’ is not a folder. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,8 +158,8 @@ func checkCopySyntaxTypeC(srcURLs []string, tgtURL string) {
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if srcContent.Type.IsRegular() { // Ellipses is supported only for directories.
|
||||
console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
if srcContent.Type.IsRegular() { // Ellipses is supported only for folders.
|
||||
console.Fatalf("Source ‘%s’ is not a folder. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
|
||||
_, tgtContent, err := url2Stat(tgtURL)
|
||||
@@ -167,7 +168,7 @@ func checkCopySyntaxTypeC(srcURLs []string, tgtURL string) {
|
||||
console.Fatalf("Unable to stat target ‘%s’. %s\n", tgtURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if !tgtContent.Type.IsDir() {
|
||||
console.Fatalf("Target ‘%s’ is not a directory. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
console.Fatalf("Target ‘%s’ is not a folder. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +182,8 @@ func checkCopySyntaxTypeD(srcURLs []string, tgtURL string) {
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if !srcContent.Type.IsDir() { // Ellipses is supported only for directories.
|
||||
console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
if !srcContent.Type.IsDir() { // Ellipses is supported only for folders.
|
||||
console.Fatalf("Source ‘%s’ is not a folder. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
} else { // Regular URL.
|
||||
_, srcContent, err := url2Stat(srcURL)
|
||||
@@ -191,7 +192,7 @@ func checkCopySyntaxTypeD(srcURLs []string, tgtURL string) {
|
||||
console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if srcContent.Type.IsDir() {
|
||||
console.Fatalf("Source ‘%s’ is a directory. Use ‘%s...’ argument to copy this directory and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
console.Fatalf("Source ‘%s’ is a folder. Use ‘%s...’ argument to copy this folder and its contents recursively. %s\n", srcURL, srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
if !srcContent.Type.IsRegular() {
|
||||
console.Fatalf("Source ‘%s’ is not a file. %s\n", srcURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
@@ -204,7 +205,7 @@ func checkCopySyntaxTypeD(srcURLs []string, tgtURL string) {
|
||||
console.Fatalf("Unable to stat target ‘%s’. %s\n", tgtURL, NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
if !tgtContent.Type.IsDir() {
|
||||
console.Fatalf("Target ‘%s’ is not a directory. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
console.Fatalf("Target ‘%s’ is not a folder. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +218,11 @@ func guessCopyURLType(sourceURLs []string, targetURL string) copyURLsType {
|
||||
if sourceURLs == nil { // Source list is empty
|
||||
return copyURLsTypeInvalid
|
||||
}
|
||||
for _, sourceURL := range sourceURLs {
|
||||
if sourceURL == "" { // One of the source is empty
|
||||
return copyURLsTypeInvalid
|
||||
}
|
||||
}
|
||||
if len(sourceURLs) == 1 { // 1 Source, 1 Target
|
||||
switch {
|
||||
// Type C
|
||||
@@ -263,7 +269,7 @@ func prepareCopyURLsTypeB(sourceURL string, targetURL string) copyURLs {
|
||||
return copyURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
|
||||
}
|
||||
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a directory and exists.
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a folder and exists.
|
||||
sourceURLParse, err := client.Parse(sourceURL)
|
||||
if err != nil {
|
||||
return copyURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
|
||||
@@ -290,7 +296,7 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan copyURLs {
|
||||
return
|
||||
}
|
||||
|
||||
// add `/` after trimming off `...` to emulate directories
|
||||
// add `/` after trimming off `...` to emulate folders
|
||||
sourceURL = stripRecursiveURL(sourceURL)
|
||||
sourceClient, sourceContent, err := url2Stat(sourceURL)
|
||||
if err != nil {
|
||||
@@ -317,7 +323,7 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan copyURLs {
|
||||
continue
|
||||
}
|
||||
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a directory and exists.
|
||||
// All OK.. We can proceed. Type B: source is a file, target is a folder and exists.
|
||||
sourceURLParse, err := client.Parse(sourceURL)
|
||||
if err != nil {
|
||||
copyURLsCh <- copyURLs{Error: NewIodine(iodine.New(errInvalidSource{URL: sourceURL}, nil))}
|
||||
@@ -363,7 +369,7 @@ func prepareCopyURLsTypeD(sourceURLs []string, targetURL string) <-chan copyURLs
|
||||
}
|
||||
|
||||
for _, sourceURL := range sourceURLs {
|
||||
// Target is directory. Possibilities are only Type B and C
|
||||
// Target is folder. Possibilities are only Type B and C
|
||||
// Is it a recursive URL "..."?
|
||||
if isURLRecursive(sourceURL) {
|
||||
for cURLs := range prepareCopyURLsTypeC(sourceURL, targetURL) {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ EXAMPLES:
|
||||
1. Compare foo.ogg on a local filesystem with bar.ogg on Amazon AWS cloud storage.
|
||||
$ mc {{.Name}} foo.ogg https://s3.amazonaws.com/jukebox/bar.ogg
|
||||
|
||||
2. Compare two different directories on a local filesystem.
|
||||
2. Compare two different folders on a local filesystem.
|
||||
$ mc {{.Name}} ~/Photos /Media/Backup/Photos
|
||||
|
||||
`,
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ EXAMPLES:
|
||||
1. Create a bucket on Amazon S3 object storage.
|
||||
$ mc mb https://s3.amazonaws.com/public-document-store
|
||||
|
||||
3. Make a directory on local filesystem, including its parent directories as needed.
|
||||
3. Make a folder on local filesystem, including its parent folders as needed.
|
||||
$ mc mb ~/
|
||||
|
||||
3. Create a bucket on Minio object storage.
|
||||
|
||||
@@ -140,13 +140,13 @@ func (e errInvalidTheme) Error() string {
|
||||
type errTargetIsNotDir errInvalidURL
|
||||
|
||||
func (e errTargetIsNotDir) Error() string {
|
||||
return "Target ‘" + e.URL + "’ is not a directory."
|
||||
return "Target ‘" + e.URL + "’ is not a folder."
|
||||
}
|
||||
|
||||
type errTargetNotFound errInvalidURL
|
||||
|
||||
func (e errTargetNotFound) Error() string {
|
||||
return "Target directory ‘" + e.URL + "’ does not exist."
|
||||
return "Target folder ‘" + e.URL + "’ does not exist."
|
||||
}
|
||||
|
||||
type errSourceNotRecursive errInvalidURL
|
||||
@@ -158,7 +158,7 @@ func (e errSourceNotRecursive) Error() string {
|
||||
type errSourceIsNotDir errTargetIsNotDir
|
||||
|
||||
func (e errSourceIsNotDir) Error() string {
|
||||
return "Source ‘" + e.URL + "’ is not a directory."
|
||||
return "Source ‘" + e.URL + "’ is not a folder."
|
||||
}
|
||||
|
||||
type errSourceListEmpty errInvalidArgument
|
||||
|
||||
@@ -34,7 +34,7 @@ var (
|
||||
configFlag = cli.StringFlag{
|
||||
Name: "config, C",
|
||||
Value: mustGetMcConfigDir(),
|
||||
Usage: "Path to configuration directory",
|
||||
Usage: "Path to configuration folder",
|
||||
}
|
||||
|
||||
quietFlag = cli.BoolFlag{
|
||||
|
||||
@@ -42,7 +42,7 @@ func parseContent(c *client.Content) Content {
|
||||
// guess file type
|
||||
content.Filetype = func() string {
|
||||
if c.Type.IsDir() {
|
||||
return "directory"
|
||||
return "folder"
|
||||
}
|
||||
return "file"
|
||||
}()
|
||||
|
||||
@@ -37,7 +37,7 @@ func checkConfig() {
|
||||
|
||||
if !isSessionDirExists() {
|
||||
if err := createSessionDir(); err != nil {
|
||||
console.Fatalf("Unable to create session directory. %s\n", err)
|
||||
console.Fatalf("Unable to create session folder. %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ EXAMPLES:
|
||||
1. Create a bucket on Amazon S3 object storage.
|
||||
$ mc {{.Name}} https://s3.amazonaws.com/public-document-store
|
||||
|
||||
3. Make a directory on local filesystem, including its parent directories as needed.
|
||||
3. Make a folder on local filesystem, including its parent folders as needed.
|
||||
$ mc {{.Name}} ~/
|
||||
|
||||
3. Create a bucket on Minio object storage.
|
||||
|
||||
@@ -107,18 +107,18 @@ func (s *MySuite) TestList(c *C) {
|
||||
c.Assert(len(contents), Equals, 4)
|
||||
|
||||
var regularFiles int
|
||||
var directories int
|
||||
var folders int
|
||||
for _, content := range contents {
|
||||
if content.Type.IsRegular() {
|
||||
regularFiles++
|
||||
continue
|
||||
}
|
||||
if content.Type.IsDir() {
|
||||
directories++
|
||||
folders++
|
||||
}
|
||||
}
|
||||
c.Assert(regularFiles, Equals, 3)
|
||||
c.Assert(directories, Equals, 1)
|
||||
c.Assert(folders, Equals, 1)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestPutBucket(c *C) {
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ func (c Content) String() string {
|
||||
message := console.Time("[%s] ", c.Time)
|
||||
message = message + console.Size("%6s ", c.Size)
|
||||
message = func() string {
|
||||
if c.Filetype == "directory" {
|
||||
if c.Filetype == "folder" {
|
||||
return message + console.Dir("%s", c.Name)
|
||||
}
|
||||
return message + console.File("%s", c.Name)
|
||||
|
||||
+2
-2
@@ -122,7 +122,7 @@ func runSessionCmd(ctx *cli.Context) {
|
||||
}
|
||||
if !isSessionDirExists() {
|
||||
if err := createSessionDir(); err != nil {
|
||||
console.Fatalf("Unable to create session directory. %s\n", err)
|
||||
console.Fatalf("Unable to create session folder. %s\n", err)
|
||||
}
|
||||
}
|
||||
switch strings.TrimSpace(ctx.Args().First()) {
|
||||
@@ -154,7 +154,7 @@ func runSessionCmd(ctx *cli.Context) {
|
||||
|
||||
savedCwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
console.Fatalln("Unable to verify your current working directory. %s\n", err)
|
||||
console.Fatalln("Unable to verify your current working folder. %s\n", err)
|
||||
}
|
||||
if s.Header.RootPath != "" {
|
||||
// chdir to RootPath
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ func loadSessionV1(sid string) (*sessionV1, error) {
|
||||
func getSessionIDsV1() (sids []string) {
|
||||
sessionList, err := filepath.Glob(getSessionDir() + "/*")
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to list session directory ‘%s’, %s", getSessionDir(), NewIodine(iodine.New(err, nil)))
|
||||
console.Fatalf("Unable to list session folder ‘%s’, %s", getSessionDir(), NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
|
||||
for _, path := range sessionList {
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ func migrateSessionV1ToV2() {
|
||||
type sessionV2Header struct {
|
||||
Version string `json:"version"`
|
||||
When time.Time `json:"time"`
|
||||
RootPath string `json:"working-directory"`
|
||||
RootPath string `json:"working-folder"`
|
||||
CommandType string `json:"command-type"`
|
||||
CommandArgs []string `json:"cmd-args"`
|
||||
LastCopied string `json:"last-copied"`
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ func getSessionDataFile(sid string) string {
|
||||
func getSessionIDs() (sids []string) {
|
||||
sessionList, err := filepath.Glob(getSessionDir() + "/*.json")
|
||||
if err != nil {
|
||||
console.Fatalf("Unable to list session directory ‘%s’, %s", getSessionDir(), NewIodine(iodine.New(err, nil)))
|
||||
console.Fatalf("Unable to list session folder ‘%s’, %s", getSessionDir(), NewIodine(iodine.New(err, nil)))
|
||||
}
|
||||
|
||||
for _, path := range sessionList {
|
||||
|
||||
Reference in New Issue
Block a user