Merge pull request #251 from harshavardhana/pr_out_handle_individual_objects_too
This commit is contained in:
commit
4bdfe61701
|
@ -385,38 +385,56 @@ func (storage *storage) ListObjects(bucket string, resources mstorage.BucketReso
|
||||||
// TODO handle resources.Marker
|
// TODO handle resources.Marker
|
||||||
switch true {
|
switch true {
|
||||||
case resources.Delimiter != "" && resources.Prefix == "":
|
case resources.Delimiter != "" && resources.Prefix == "":
|
||||||
delimited := delimiter(name, resources.Delimiter)
|
delimitedName := delimiter(name, resources.Delimiter)
|
||||||
switch true {
|
switch true {
|
||||||
case delimited == file.Name():
|
case delimitedName == "":
|
||||||
metadata := mstorage.ObjectMetadata{
|
metadata := mstorage.ObjectMetadata{
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Key: name,
|
Key: name,
|
||||||
Created: file.ModTime(),
|
Created: file.ModTime(),
|
||||||
Size: file.Size(),
|
Size: file.Size(),
|
||||||
ETag: bucket + "#" + name,
|
ETag: bucket + "#" + file.Name(),
|
||||||
}
|
}
|
||||||
metadataList = append(metadataList, metadata)
|
metadataList = append(metadataList, metadata)
|
||||||
case delimited != "":
|
case delimitedName == file.Name():
|
||||||
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimited)
|
|
||||||
}
|
|
||||||
case resources.Delimiter != "" && strings.HasPrefix(name, resources.Prefix):
|
|
||||||
_internal := strings.TrimPrefix(name, resources.Prefix)
|
|
||||||
delimited := delimiter(_internal, resources.Delimiter)
|
|
||||||
switch true {
|
|
||||||
case delimited == file.Name():
|
|
||||||
metadata := mstorage.ObjectMetadata{
|
metadata := mstorage.ObjectMetadata{
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Key: _internal,
|
Key: name,
|
||||||
Created: file.ModTime(),
|
Created: file.ModTime(),
|
||||||
Size: file.Size(),
|
Size: file.Size(),
|
||||||
ETag: bucket + "#" + name,
|
ETag: bucket + "#" + file.Name(),
|
||||||
}
|
}
|
||||||
metadataList = append(metadataList, metadata)
|
metadataList = append(metadataList, metadata)
|
||||||
case delimited != "":
|
case delimitedName != "":
|
||||||
if delimited == resources.Delimiter {
|
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimitedName)
|
||||||
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, resources.Prefix+delimited)
|
}
|
||||||
|
case resources.Delimiter != "" && strings.HasPrefix(name, resources.Prefix):
|
||||||
|
trimmedName := strings.TrimPrefix(name, resources.Prefix)
|
||||||
|
delimitedName := delimiter(trimmedName, resources.Delimiter)
|
||||||
|
switch true {
|
||||||
|
case name == resources.Prefix:
|
||||||
|
metadata := mstorage.ObjectMetadata{
|
||||||
|
Bucket: bucket,
|
||||||
|
Key: file.Name(),
|
||||||
|
Created: file.ModTime(),
|
||||||
|
Size: file.Size(),
|
||||||
|
ETag: bucket + "#" + file.Name(),
|
||||||
|
}
|
||||||
|
metadataList = append(metadataList, metadata)
|
||||||
|
case delimitedName == file.Name():
|
||||||
|
metadata := mstorage.ObjectMetadata{
|
||||||
|
Bucket: bucket,
|
||||||
|
Key: trimmedName,
|
||||||
|
Created: file.ModTime(),
|
||||||
|
Size: file.Size(),
|
||||||
|
ETag: bucket + "#" + file.Name(),
|
||||||
|
}
|
||||||
|
metadataList = append(metadataList, metadata)
|
||||||
|
case delimitedName != "":
|
||||||
|
if delimitedName == resources.Delimiter {
|
||||||
|
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, resources.Prefix+delimitedName)
|
||||||
} else {
|
} else {
|
||||||
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimited)
|
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimitedName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(name, resources.Prefix):
|
case strings.HasPrefix(name, resources.Prefix):
|
||||||
|
|
Loading…
Reference in a new issue