@@ -635,15 +635,18 @@ func (z *erasureServerPools) getPoolIdxNoLock(ctx context.Context, bucket, objec
635635// if none are found falls back to most available space pool, this function is
636636// designed to be only used by PutObject, CopyObject (newObject creation) and NewMultipartUpload.
637637func (z * erasureServerPools ) getPoolIdx (ctx context.Context , bucket , object string , size int64 ) (idx int , err error ) {
638- idx , err = z .getPoolIdxExistingWithOpts (ctx , bucket , object , ObjectOptions {
638+ pinfo , _ , err : = z .getPoolInfoExistingWithOpts (ctx , bucket , object , ObjectOptions {
639639 SkipDecommissioned : true ,
640640 SkipRebalancing : true ,
641641 })
642+
642643 if err != nil && ! isErrObjectNotFound (err ) {
643- return idx , err
644+ return - 1 , err
644645 }
645646
646- if isErrObjectNotFound (err ) {
647+ idx = pinfo .Index
648+ if isErrObjectNotFound (err ) || pinfo .Err == nil {
649+ // will generate a temp object
647650 idx = z .getAvailablePoolIdx (ctx , bucket , object , size )
648651 if idx < 0 {
649652 return - 1 , toObjectErr (errDiskFull )
@@ -1089,6 +1092,10 @@ func (z *erasureServerPools) PutObject(ctx context.Context, bucket string, objec
10891092
10901093 object = encodeDirObject (object )
10911094 if z .SinglePool () {
1095+ _ , err := z .getPoolIdx (ctx , bucket , object , data .Size ())
1096+ if err != nil {
1097+ return ObjectInfo {}, err
1098+ }
10921099 return z .serverPools [0 ].PutObject (ctx , bucket , object , data , opts )
10931100 }
10941101
@@ -1816,6 +1823,10 @@ func (z *erasureServerPools) PutObjectPart(ctx context.Context, bucket, object,
18161823 }
18171824
18181825 if z .SinglePool () {
1826+ _ , err := z .getPoolIdx (ctx , bucket , object , data .Size ())
1827+ if err != nil {
1828+ return PartInfo {}, err
1829+ }
18191830 return z .serverPools [0 ].PutObjectPart (ctx , bucket , object , uploadID , partID , data , opts )
18201831 }
18211832
0 commit comments