mirror of
https://github.com/minio/minio.git
synced 2025-03-31 09:43:43 -04:00
XL/Multipart: isMultipartUpload() checks for presence of uploads.json on a random disk.
This commit is contained in:
parent
3487b3c095
commit
616a257bfa
@ -259,45 +259,9 @@ func cleanupUploadedParts(bucket, object, uploadID string, storageDisks ...Stora
|
|||||||
|
|
||||||
// Returns if the prefix is a multipart upload.
|
// Returns if the prefix is a multipart upload.
|
||||||
func (xl xlObjects) isMultipartUpload(bucket, prefix string) bool {
|
func (xl xlObjects) isMultipartUpload(bucket, prefix string) bool {
|
||||||
// Create errs and volInfo slices of storageDisks size.
|
disk := xl.getRandomDisk() // Choose a random disk.
|
||||||
var errs = make([]error, len(xl.storageDisks))
|
_, err := disk.StatFile(bucket, pathJoin(prefix, uploadsJSONFile))
|
||||||
|
return err == nil
|
||||||
// Allocate a new waitgroup.
|
|
||||||
var wg = &sync.WaitGroup{}
|
|
||||||
for index, disk := range xl.storageDisks {
|
|
||||||
wg.Add(1)
|
|
||||||
// Stat file on all the disks in a routine.
|
|
||||||
go func(index int, disk StorageAPI) {
|
|
||||||
defer wg.Done()
|
|
||||||
_, err := disk.StatFile(bucket, path.Join(prefix, uploadsJSONFile))
|
|
||||||
if err != nil {
|
|
||||||
errs[index] = err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
errs[index] = nil
|
|
||||||
}(index, disk)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for all the Stat operations to finish.
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
var errFileNotFoundCount int
|
|
||||||
for _, err := range errs {
|
|
||||||
if err != nil {
|
|
||||||
if err == errFileNotFound {
|
|
||||||
errFileNotFoundCount++
|
|
||||||
// If we have errors with file not found greater than allowed read
|
|
||||||
// quorum we return err as errFileNotFound.
|
|
||||||
if errFileNotFoundCount > len(xl.storageDisks)-xl.readQuorum {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
errorIf(err, "Unable to access file "+path.Join(bucket, prefix))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// listUploadsInfo - list all uploads info.
|
// listUploadsInfo - list all uploads info.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user