// Mkdir creates the bucket if it doesn't exist
Mkdir creates the bucket if it doesn't exist
// Mkdir creates the bucket if it doesn ' t exist
func (f *Fs) Mkdir(ctx context.Context, dir string) error {
	f.bucketOKMu.Lock()
	defer f.bucketOKMu.Unlock()
	if f.bucketOK {
		return nil
	}
	bucketInit, err := f.svc.Bucket(f.bucket, f.zone)
	if err != nil {
		return err
	}
	retries := 0
	for retries <= 120 {
		statistics, err := bucketInit.GetStatistics()
		if statistics == nil || err != nil {
			break
		}
		switch *statistics.Status {
		case "deleted":
			fs.Debugf(f, "Wait for qingstor sync bucket status, retries: %d", retries)
			time.Sleep(time.Second * 1)
			retries++
			continue
		default:
			break
		}
		break
	}
	if !f.bucketDeleted {
		exists, err := f.dirExists()
		if err == nil {
			f.bucketOK = exists
		}
		if err != nil || exists {
			return err
		}
	}
	_, err = bucketInit.Put()
	if e, ok := err.(*qsErr.QingStorError); ok {
		if e.StatusCode == http.StatusConflict {
			err = nil
		}
	}
	if err == nil {
		f.bucketOK = true
		f.bucketDeleted = false
	}
	return err
}
func ( f * Fs ) Mkdir ( ctx context . Context , dir string ) error { f . bucketOKMu . Lock ( ) defer f . bucketOKMu . Unlock ( ) if f . bucketOK { return nil } bucketInit , err := f . svc . Bucket ( f . bucket , f . zone ) if err != nil { return err } retries := 0 for retries <= 120 { statistics , err := bucketInit . GetStatistics ( ) if statistics == nil || err != nil { break } switch * statistics . Status { case " " : fs . Debugf ( f , " " , retries ) time . Sleep ( time . Second * 1 ) retries ++ continue default : break } break } if ! f . bucketDeleted { exists , err := f . dirExists ( ) if err == nil { f . bucketOK = exists } if err != nil || exists { return err } } _ , err = bucketInit . Put ( ) if e , ok := err . ( * qsErr . QingStorError ) ; ok { if e . StatusCode == http . StatusConflict { err = nil } } if err == nil { f . bucketOK = true f . bucketDeleted = false } return err }
Mkdir creates the bucket if it doesn't exist
Mkdir creates the bucket if it doesn ' t exist
/* When delete a bucket, qingstor need about 60 second to sync status;
	So, need wait for it sync end if we try to operation a just deleted bucket
	*/