func Unzip(
	ctx context.Context,
	readerAt io.ReaderAt,
	size int64,
	writeBucket storage.WriteBucket,
	mapper storage.Mapper,
	stripComponentCount uint32,
) error {
	if size < 0 {
		return fmt.Errorf("unknown size to unzip: %d", int(size))
	}
	if size == 0 {
		return nil
	}
	zipReader, err := zip.NewReader(readerAt, size)
	if err != nil {
		return err
	}
	walkChecker := storageutil.NewWalkChecker()
	// reads can be done concurrently in the future
	for _, zipFile := range zipReader.File {
		if err := walkChecker.Check(ctx); err != nil {
			return err
		}
		path, ok, err := unmapArchivePath(zipFile.Name, mapper, stripComponentCount)
		if err != nil {
			return err
		}
		if !ok {
			continue
		}
		if zipFile.FileInfo().Mode().IsRegular() {
			if err := copyZipFile(ctx, writeBucket, zipFile, path); err != nil {
				return err
			}
		}
	}
	return nil
}
// Unzip unzips the given zip archive from the reader into the bucket.
//
// Only regular files are added to the bucket.
//
// Paths from the zip archive will be mapped before adding to the bucket.
// Mapper can be nil.
// StripComponents happens before the mapper.
Unzip unzips the given zip archive from the reader into the bucket.

Only regular files are added to the bucket.

Paths from the zip archive will be mapped before adding to the bucket.
Mapper can be nil.
StripComponents happens before the mapper.
// Unzip unzips the given zip archive from the reader into the bucket . // // Only regular files are added to the bucket . // // Paths from the zip archive will be mapped before adding to the bucket . // Mapper can be nil . // StripComponents happens before the mapper .
func Unzip(
	ctx context.Context,
	readerAt io.ReaderAt,
	size int64,
	writeBucket storage.WriteBucket,
	mapper storage.Mapper,
	stripComponentCount uint32,
) error {
	if size < 0 {
		return fmt.Errorf("unknown size to unzip: %d", int(size))
	}
	if size == 0 {
		return nil
	}
	zipReader, err := zip.NewReader(readerAt, size)
	if err != nil {
		return err
	}
	walkChecker := storageutil.NewWalkChecker()
	for _, zipFile := range zipReader.File {
		if err := walkChecker.Check(ctx); err != nil {
			return err
		}
		path, ok, err := unmapArchivePath(zipFile.Name, mapper, stripComponentCount)
		if err != nil {
			return err
		}
		if !ok {
			continue
		}
		if zipFile.FileInfo().Mode().IsRegular() {
			if err := copyZipFile(ctx, writeBucket, zipFile, path); err != nil {
				return err
			}
		}
	}
	return nil
}
func Unzip ( ctx context . Context , readerAt io . ReaderAt , size int64 , writeBucket storage . WriteBucket , mapper storage . Mapper , stripComponentCount uint32 , ) error { if size < 0 { return fmt . Errorf ( " " , int ( size ) ) } if size == 0 { return nil } zipReader , err := zip . NewReader ( readerAt , size ) if err != nil { return err } walkChecker := storageutil . NewWalkChecker ( ) for _ , zipFile := range zipReader . File { if err := walkChecker . Check ( ctx ) ; err != nil { return err } path , ok , err := unmapArchivePath ( zipFile . Name , mapper , stripComponentCount ) if err != nil { return err } if ! ok { continue } if zipFile . FileInfo ( ) . Mode ( ) . IsRegular ( ) { if err := copyZipFile ( ctx , writeBucket , zipFile , path ) ; err != nil { return err } } } return nil }
Unzip unzips the given zip archive from the reader into the bucket.
Unzip unzips the given zip archive from the reader into the bucket .
// reads can be done concurrently in the future