Merge pull request #251 from harshavardhana/pr_out_handle_individual_objects_too

master
Harshavardhana 10 years ago
commit 4bdfe61701
  1. 46
      pkg/storage/fs/fs.go

@ -385,38 +385,56 @@ func (storage *storage) ListObjects(bucket string, resources mstorage.BucketReso
// TODO handle resources.Marker
switch true {
case resources.Delimiter != "" && resources.Prefix == "":
delimited := delimiter(name, resources.Delimiter)
delimitedName := delimiter(name, resources.Delimiter)
switch true {
case delimited == file.Name():
case delimitedName == "":
metadata := mstorage.ObjectMetadata{
Bucket: bucket,
Key: name,
Created: file.ModTime(),
Size: file.Size(),
ETag: bucket + "#" + name,
ETag: bucket + "#" + file.Name(),
}
metadataList = append(metadataList, metadata)
case delimited != "":
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimited)
case delimitedName == file.Name():
metadata := mstorage.ObjectMetadata{
Bucket: bucket,
Key: name,
Created: file.ModTime(),
Size: file.Size(),
ETag: bucket + "#" + file.Name(),
}
metadataList = append(metadataList, metadata)
case delimitedName != "":
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimitedName)
}
case resources.Delimiter != "" && strings.HasPrefix(name, resources.Prefix):
_internal := strings.TrimPrefix(name, resources.Prefix)
delimited := delimiter(_internal, resources.Delimiter)
trimmedName := strings.TrimPrefix(name, resources.Prefix)
delimitedName := delimiter(trimmedName, resources.Delimiter)
switch true {
case delimited == file.Name():
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: _internal,
Key: trimmedName,
Created: file.ModTime(),
Size: file.Size(),
ETag: bucket + "#" + name,
ETag: bucket + "#" + file.Name(),
}
metadataList = append(metadataList, metadata)
case delimited != "":
if delimited == resources.Delimiter {
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, resources.Prefix+delimited)
case delimitedName != "":
if delimitedName == resources.Delimiter {
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, resources.Prefix+delimitedName)
} else {
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimited)
resources.CommonPrefixes = appendUniq(resources.CommonPrefixes, delimitedName)
}
}
case strings.HasPrefix(name, resources.Prefix):

Loading…
Cancel
Save