Do not enforce mirror source to have ... convention, let it be recursive always

This commit is contained in:
Harshavardhana
2015-09-01 15:43:57 -07:00
parent fee0ebf6a2
commit 8aba0aed50
2 changed files with 9 additions and 14 deletions
+6 -6
View File
@@ -41,23 +41,23 @@ var mirrorCmd = cli.Command{
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}} SOURCE TARGET [TARGET ...]
mc {{.Name}} SOURCE TARGET [TARGET...]
EXAMPLES:
1. Mirror a bucket recursively from Minio cloud storage to multiple buckets on Amazon S3 cloud storage.
$ mc {{.Name}} https://play.minio.io:9000/photos/2014... https://s3.amazonaws.com/backup-photos https://s3-west-1.amazonaws.com/local-photos
$ mc {{.Name}} https://play.minio.io:9000/photos/2014 https://s3.amazonaws.com/backup-photos https://s3-west-1.amazonaws.com/local-photos
2. Mirror a local folder recursively to Minio cloud storage and Amazon S3 cloud storage.
$ mc {{.Name}} backup/... https://play.minio.io:9000/archive https://s3.amazonaws.com/archive
$ mc {{.Name}} backup/ https://play.minio.io:9000/archive https://s3.amazonaws.com/archive
3. Mirror a bucket from aliased Amazon S3 cloud storage to multiple folders on Windows.
$ mc {{.Name}} s3/documents/2014/... C:\backup\2014 C:\shared\volume\backup\2014
$ mc {{.Name}} s3/documents/2014/ C:\backup\2014 C:\shared\volume\backup\2014
4. Mirror a local folder of non english character recursively to Amazon s3 cloud storage and Minio cloud storage.
$ mc {{.Name}} 本語/... s3/mylocaldocuments play/backup
$ mc {{.Name}} 本語/ s3/mylocaldocuments play/backup
5. Mirror a local folder with space characters to Amazon s3 cloud storage
$ mc {{.Name}} 'workdir/documents/Aug 2015...' s3/miniocloud
$ mc {{.Name}} 'workdir/documents/Aug 2015' s3/miniocloud
`,
}
+3 -8
View File
@@ -63,17 +63,13 @@ func checkMirrorSyntax(ctx *cli.Context) {
tgtURLs := URLs[1:]
/****** Generic rules *******/
// Source cannot be a folder (except when recursive)
if !isURLRecursive(srcURL) {
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("Source ‘%s’ is not recursive. Use ‘%s...’ as argument to mirror recursively.", srcURL, srcURL))
}
// Recursive source URL.
newSrcURL := stripRecursiveURL(srcURL)
_, srcContent, err := url2Stat(newSrcURL)
fatalIf(err.Trace(srcURL), "Unable to stat source ‘"+newSrcURL+"’.")
if srcContent.Type.IsRegular() { // Ellipses is supported only for folders.
fatalIf(errInvalidArgument().Trace(), "Source ‘"+srcURL+"’ is not a folder.")
if !srcContent.Type.IsDir() {
fatalIf(errInvalidArgument().Trace(srcContent.Name, srcContent.Type.String()), fmt.Sprintf("Source ‘%s’ is not a folder. Only folders are supported by mirror.", srcURL))
}
if len(tgtURLs) == 0 && tgtURLs == nil {
@@ -131,7 +127,7 @@ func deltaSourceTargets(sourceClnt client.Client, targetClnts []client.Client) <
for targetContentCh := range targetClnt.List(true) {
if targetContentCh.Err != nil {
mirrorURLsCh <- mirrorURLs{Error: targetContentCh.Err.Trace()}
return
continue
}
if targetContentCh.Content.Type.IsRegular() {
targetTrie.Insert(patricia.Prefix(targetContentCh.Content.Name), struct{}{})
@@ -187,7 +183,6 @@ func prepareMirrorURLs(sourceURL string, targetURLs []string) <-chan mirrorURLs
}
targetClnts := make([]client.Client, len(targetURLs))
for i, targetURL := range targetURLs {
targetURL = stripRecursiveURL(targetURL)
targetClnt, targetContent, err := url2Stat(targetURL)
if err != nil {
mirrorURLsCh <- mirrorURLs{Error: err.Trace(targetURL)}