Update ls docs and fix a bug

This commit is contained in:
Harshavardhana
2015-04-27 21:20:21 -07:00
parent 1e9728b7df
commit bb065502dd
2 changed files with 49 additions and 23 deletions
+21 -16
View File
@@ -135,27 +135,32 @@ FLAGS:
{{end}}{{ end }}
EXAMPLES:
1. List objects on Minio object storage
$ mc {{.Name}} http://localhost:9000/backup/
2015-03-28 12:47:50 PDT 51.00 MB 2006-Jan-1/backup.tar.gz
2015-03-31 14:46:33 PDT 55.00 MB 2006-Mar-1/backup.tar.gz
1. List objects recursively on Minio object storage
$ mc {{.Name}} http://localhost:9000/backup/...
[2015-03-28 12:47:50 PDT] 34MiB 2006-Jan-1/backup.tar.gz
[2015-03-31 14:46:33 PDT] 55MiB 2006-Mar-1/backup.tar.gz
2. List buckets on Amazon S3 object storage
$ mc {{.Name}} https://s3.amazonaws.com/
2015-01-20 15:42:00 PST rom
2015-01-15 00:05:40 PST zek
[2015-01-20 15:42:00 PST] 0B rom/
[2015-01-15 00:05:40 PST] 0B zek/
3. List buckets and objects from Minio object storage and Amazon S3 object storage
$ mc {{.Name}} https://s3.amazonaws.com/ http://localhost:9000/backup/
2015-01-20 15:42:00 PST rom
2015-01-15 00:05:40 PST zek
2015-03-28 12:47:50 PDT 51.00 MB 2006-Jan-1/backup.tar.gz
2015-03-31 14:46:33 PDT 55.00 MB 2006-Mar-1/backup.tar.gz
3. List buckets from Amazon S3 object storage and recursively list objects from Minio object storage
$ mc {{.Name}} https://s3.amazonaws.com/ http://localhost:9000/backup/...
2015-01-15 00:05:40 PST 0B zek/
2015-03-31 14:46:33 PDT 55MiB 2006-Mar-1/backup.tar.gz
4. List objects on local filesystem on Windows
$ mc {{.Name}} C:\Users\Worf
2015-03-28 12:47:50 PDT 11.00 MB Martok\Klingon Council Ministers.pdf
2015-03-31 14:46:33 PDT 15.00 MB Gowron\Khitomer Conference Details.pdf
4. List files recursively on local filesystem on Windows
$ mc {{.Name}} C:\Users\Worf\...
[2015-03-28 12:47:50 PDT] 11.00MiB Martok\Klingon Council Ministers.pdf
[2015-03-31 14:46:33 PDT] 15.00MiB Gowron\Khitomer Conference Details.pdf
5. List files non recursively on local filesystem
$ mc {{.Name}} /usr/lib/llvm-3.4
[2015-04-01 14:57:17 PDT] 12KiB lib/
[2015-04-01 14:57:17 PDT] 4.0KiB include/
[2015-04-01 14:57:10 PDT] 4.0KiB build/
[2015-04-01 14:57:07 PDT] 4.0KiB bin/
`,
}
+28 -7
View File
@@ -138,20 +138,41 @@ func (f *fsClient) listSingle(itemCh chan client.ItemOnChannel) {
Err: iodine.New(err, nil),
}
}
files, err := dir.Readdir(-1)
fi, err := dir.Stat()
if err != nil {
itemCh <- client.ItemOnChannel{
Item: nil,
Err: iodine.New(err, nil),
}
}
dir.Close()
for _, file := range files {
defer dir.Close()
if fi.Mode().IsDir() {
files, err := dir.Readdir(-1)
if err != nil {
itemCh <- client.ItemOnChannel{
Item: nil,
Err: iodine.New(err, nil),
}
}
for _, file := range files {
item := &client.Item{
Name: file.Name(),
Time: file.ModTime(),
Size: file.Size(),
FileType: file.Mode(),
}
itemCh <- client.ItemOnChannel{
Item: item,
Err: nil,
}
}
}
if fi.Mode().IsRegular() {
item := &client.Item{
Name: file.Name(),
Time: file.ModTime(),
Size: file.Size(),
FileType: file.Mode(),
Name: dir.Name(),
Time: fi.ModTime(),
Size: fi.Size(),
FileType: fi.Mode(),
}
itemCh <- client.ItemOnChannel{
Item: item,