Merge pull request #9410 from ktock/continuity-0.4.3
go.mod: github.com/containerd/continuity v0.4.3
This commit is contained in:
		
							
								
								
									
										32
									
								
								vendor/github.com/containerd/continuity/fs/copy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/github.com/containerd/continuity/fs/copy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -103,11 +103,6 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	entries, err := os.ReadDir(src)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("failed to read %s: %w", src, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := copyFileInfo(stat, src, dst); err != nil {
 | 
			
		||||
		return fmt.Errorf("failed to copy file info for %s: %w", dst, err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -116,7 +111,15 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
 | 
			
		||||
		return fmt.Errorf("failed to copy xattrs: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, entry := range entries {
 | 
			
		||||
	f, err := os.Open(src)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer f.Close()
 | 
			
		||||
 | 
			
		||||
	dr := &dirReader{f: f}
 | 
			
		||||
 | 
			
		||||
	handleEntry := func(entry os.DirEntry) error {
 | 
			
		||||
		source := filepath.Join(src, entry.Name())
 | 
			
		||||
		target := filepath.Join(dst, entry.Name())
 | 
			
		||||
 | 
			
		||||
@@ -130,7 +133,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
 | 
			
		||||
			if err := copyDirectory(target, source, inodes, o); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
			continue
 | 
			
		||||
			return nil
 | 
			
		||||
		case (fileInfo.Mode() & os.ModeType) == 0:
 | 
			
		||||
			link, err := getLinkSource(target, fileInfo, inodes)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
@@ -159,7 +162,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
 | 
			
		||||
			}
 | 
			
		||||
		default:
 | 
			
		||||
			logrus.Warnf("unsupported mode: %s: %s", source, fileInfo.Mode())
 | 
			
		||||
			continue
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := copyFileInfo(fileInfo, source, target); err != nil {
 | 
			
		||||
@@ -169,9 +172,20 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
 | 
			
		||||
		if err := copyXAttrs(target, source, o.xex, o.xeh); err != nil {
 | 
			
		||||
			return fmt.Errorf("failed to copy xattrs: %w", err)
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
	for {
 | 
			
		||||
		entry := dr.Next()
 | 
			
		||||
		if entry == nil {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := handleEntry(entry); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return dr.Err()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CopyFile copies the source file to the target.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										53
									
								
								vendor/github.com/containerd/continuity/fs/dir.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								vendor/github.com/containerd/continuity/fs/dir.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
/*
 | 
			
		||||
   Copyright The containerd Authors.
 | 
			
		||||
 | 
			
		||||
   Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
   you may not use this file except in compliance with the License.
 | 
			
		||||
   You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
       http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
   Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
   distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
   See the License for the specific language governing permissions and
 | 
			
		||||
   limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package fs
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"io"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type dirReader struct {
 | 
			
		||||
	buf []os.DirEntry
 | 
			
		||||
	f   *os.File
 | 
			
		||||
	err error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *dirReader) Next() os.DirEntry {
 | 
			
		||||
	if len(r.buf) == 0 {
 | 
			
		||||
		infos, err := r.f.ReadDir(32)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			if err != io.EOF {
 | 
			
		||||
				r.err = err
 | 
			
		||||
			}
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
		r.buf = infos
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(r.buf) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	out := r.buf[0]
 | 
			
		||||
	r.buf[0] = nil
 | 
			
		||||
	r.buf = r.buf[1:]
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *dirReader) Err() error {
 | 
			
		||||
	return r.err
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user