mirror of
https://github.com/minio/minio.git
synced 2025-11-23 11:07:50 -05:00
Accessing dir as object should return ObjectNotFound
This commit is contained in:
@@ -105,10 +105,24 @@ func (storage *storage) CopyObjectToWriter(w io.Writer, bucket string, object st
|
||||
|
||||
objectPath := path.Join(storage.root, bucket, object)
|
||||
|
||||
file, err := os.Open(objectPath)
|
||||
if err != nil {
|
||||
return 0, mstorage.EmbedError(bucket, object, err)
|
||||
filestat, err := os.Stat(objectPath)
|
||||
switch err := err.(type) {
|
||||
case nil:
|
||||
{
|
||||
if filestat.IsDir() {
|
||||
return 0, mstorage.ObjectNotFound{Bucket: bucket, Object: object}
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
if os.IsNotExist(err) {
|
||||
return 0, mstorage.ObjectNotFound{Bucket: bucket, Object: object}
|
||||
} else {
|
||||
return 0, mstorage.EmbedError(bucket, object, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
file, err := os.Open(objectPath)
|
||||
count, err := io.Copy(w, file)
|
||||
if err != nil {
|
||||
return count, mstorage.EmbedError(bucket, object, err)
|
||||
|
||||
Reference in New Issue
Block a user