Exemplo n.º 1
0
func (sto *s3Storage) StatBlobs(dest chan<- blob.SizedInfoRef, blobs []blob.Ref) error {
	var wg syncutil.Group

	for _, br := range blobs {
		br := br
		statGate.Start()

		wg.Go(func() error {
			defer statGate.Done()
			size, err := sto.s3Client.Stat(br.String(), sto.bucket)

			if err == nil {
				dest <- blob.SizedInfoRef{Ref: br, Size: uint32(size)}
				return nil
			}

			if err == os.ErrNotExist {
				return nil
			}

			return fmt.Errorf("error statting %v: %v", br, err)
		})
	}
	return wg.Err()
}
Exemplo n.º 2
0
func (sto *swiftStorage) StatBlobs(dest chan<- blob.SizedInfoRef, blobs []blob.Ref) error {
	var wg syncutil.Group

	for _, br := range blobs {
		br := sto.createPathRef(br)
		statGate.Start()
		wg.Go(func() error {
			defer statGate.Done()
			ref, cont := sto.refContainer(br)
			log.Println("REF:", ref, cont)
			info, _, err := sto.conn.Object(cont, ref)
			log.Println("Stat:", info, err, ref, br.Path)

			if err == nil {
				dest <- blob.SizedInfoRef{
					Ref:  br,
					Size: uint32(info.Bytes),
					MD5:  info.Hash,
				}
				return nil
			}
			if err == swift.ObjectNotFound {
				return nil
			}
			return fmt.Errorf("error statting %v: %v", br, err)
		})
	}
	return wg.Err()
}
Exemplo n.º 3
0
func (sto *s3Storage) RemoveBlobs(blobs []blob.Ref) error {
	var wg syncutil.Group

	for _, blob := range blobs {
		blob := blob
		removeGate.Start()
		wg.Go(func() error {
			defer removeGate.Done()
			return sto.s3Client.Delete(sto.bucket, blob.String())
		})
	}
	return wg.Err()

}
Exemplo n.º 4
0
func (sto *swiftStorage) RemoveBlobs(blobs []blob.Ref) error {
	var wg syncutil.Group

	for _, br := range blobs {
		br := br
		removeGate.Start()
		wg.Go(func() error {
			defer removeGate.Done()
			ref, cont := sto.refContainer(br)
			log.Println("Remove: ", cont, ref)
			return sto.conn.ObjectDelete(cont, ref)
		})
	}
	return wg.Err()
}