full diff: https://github.com/containerd/continuity/compare/v0.4.3...v0.4.2
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
| ... | ... |
@@ -26,7 +26,7 @@ require ( |
| 26 | 26 |
github.com/cloudflare/cfssl v1.6.4 |
| 27 | 27 |
github.com/containerd/cgroups/v3 v3.0.3 |
| 28 | 28 |
github.com/containerd/containerd v1.7.13 |
| 29 |
- github.com/containerd/continuity v0.4.2 |
|
| 29 |
+ github.com/containerd/continuity v0.4.3 |
|
| 30 | 30 |
github.com/containerd/fifo v1.1.0 |
| 31 | 31 |
github.com/containerd/log v0.1.0 |
| 32 | 32 |
github.com/containerd/typeurl/v2 v2.1.1 |
| ... | ... |
@@ -309,8 +309,8 @@ github.com/containerd/containerd v1.7.13 h1:wPYKIeGMN8vaggSKuV1X0wZulpMz4CrgEsZd |
| 309 | 309 |
github.com/containerd/containerd v1.7.13/go.mod h1:zT3up6yTRfEUa6+GsITYIJNgSVL9NQ4x4h1RPzk0Wu4= |
| 310 | 310 |
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= |
| 311 | 311 |
github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo= |
| 312 |
-github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= |
|
| 313 |
-github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= |
|
| 312 |
+github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= |
|
| 313 |
+github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= |
|
| 314 | 314 |
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= |
| 315 | 315 |
github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= |
| 316 | 316 |
github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY= |
| ... | ... |
@@ -103,11 +103,6 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er |
| 103 | 103 |
} |
| 104 | 104 |
} |
| 105 | 105 |
|
| 106 |
- entries, err := os.ReadDir(src) |
|
| 107 |
- if err != nil {
|
|
| 108 |
- return fmt.Errorf("failed to read %s: %w", src, err)
|
|
| 109 |
- } |
|
| 110 |
- |
|
| 111 | 106 |
if err := copyFileInfo(stat, src, dst); err != nil {
|
| 112 | 107 |
return fmt.Errorf("failed to copy file info for %s: %w", dst, err)
|
| 113 | 108 |
} |
| ... | ... |
@@ -116,7 +111,15 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er |
| 116 | 116 |
return fmt.Errorf("failed to copy xattrs: %w", err)
|
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 |
- for _, entry := range entries {
|
|
| 119 |
+ f, err := os.Open(src) |
|
| 120 |
+ if err != nil {
|
|
| 121 |
+ return err |
|
| 122 |
+ } |
|
| 123 |
+ defer f.Close() |
|
| 124 |
+ |
|
| 125 |
+ dr := &dirReader{f: f}
|
|
| 126 |
+ |
|
| 127 |
+ handleEntry := func(entry os.DirEntry) error {
|
|
| 120 | 128 |
source := filepath.Join(src, entry.Name()) |
| 121 | 129 |
target := filepath.Join(dst, entry.Name()) |
| 122 | 130 |
|
| ... | ... |
@@ -130,7 +133,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er |
| 130 | 130 |
if err := copyDirectory(target, source, inodes, o); err != nil {
|
| 131 | 131 |
return err |
| 132 | 132 |
} |
| 133 |
- continue |
|
| 133 |
+ return nil |
|
| 134 | 134 |
case (fileInfo.Mode() & os.ModeType) == 0: |
| 135 | 135 |
link, err := getLinkSource(target, fileInfo, inodes) |
| 136 | 136 |
if err != nil {
|
| ... | ... |
@@ -159,7 +162,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er |
| 159 | 159 |
} |
| 160 | 160 |
default: |
| 161 | 161 |
logrus.Warnf("unsupported mode: %s: %s", source, fileInfo.Mode())
|
| 162 |
- continue |
|
| 162 |
+ return nil |
|
| 163 | 163 |
} |
| 164 | 164 |
|
| 165 | 165 |
if err := copyFileInfo(fileInfo, source, target); err != nil {
|
| ... | ... |
@@ -169,9 +172,20 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er |
| 169 | 169 |
if err := copyXAttrs(target, source, o.xex, o.xeh); err != nil {
|
| 170 | 170 |
return fmt.Errorf("failed to copy xattrs: %w", err)
|
| 171 | 171 |
} |
| 172 |
+ return nil |
|
| 172 | 173 |
} |
| 173 | 174 |
|
| 174 |
- return nil |
|
| 175 |
+ for {
|
|
| 176 |
+ entry := dr.Next() |
|
| 177 |
+ if entry == nil {
|
|
| 178 |
+ break |
|
| 179 |
+ } |
|
| 180 |
+ |
|
| 181 |
+ if err := handleEntry(entry); err != nil {
|
|
| 182 |
+ return err |
|
| 183 |
+ } |
|
| 184 |
+ } |
|
| 185 |
+ return dr.Err() |
|
| 175 | 186 |
} |
| 176 | 187 |
|
| 177 | 188 |
// CopyFile copies the source file to the target. |
| 178 | 189 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,53 @@ |
| 0 |
+/* |
|
| 1 |
+ Copyright The containerd Authors. |
|
| 2 |
+ |
|
| 3 |
+ Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 4 |
+ you may not use this file except in compliance with the License. |
|
| 5 |
+ You may obtain a copy of the License at |
|
| 6 |
+ |
|
| 7 |
+ http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 |
+ |
|
| 9 |
+ Unless required by applicable law or agreed to in writing, software |
|
| 10 |
+ distributed under the License is distributed on an "AS IS" BASIS, |
|
| 11 |
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 12 |
+ See the License for the specific language governing permissions and |
|
| 13 |
+ limitations under the License. |
|
| 14 |
+*/ |
|
| 15 |
+ |
|
| 16 |
+package fs |
|
| 17 |
+ |
|
| 18 |
+import ( |
|
| 19 |
+ "io" |
|
| 20 |
+ "os" |
|
| 21 |
+) |
|
| 22 |
+ |
|
| 23 |
+type dirReader struct {
|
|
| 24 |
+ buf []os.DirEntry |
|
| 25 |
+ f *os.File |
|
| 26 |
+ err error |
|
| 27 |
+} |
|
| 28 |
+ |
|
| 29 |
+func (r *dirReader) Next() os.DirEntry {
|
|
| 30 |
+ if len(r.buf) == 0 {
|
|
| 31 |
+ infos, err := r.f.ReadDir(32) |
|
| 32 |
+ if err != nil {
|
|
| 33 |
+ if err != io.EOF {
|
|
| 34 |
+ r.err = err |
|
| 35 |
+ } |
|
| 36 |
+ return nil |
|
| 37 |
+ } |
|
| 38 |
+ r.buf = infos |
|
| 39 |
+ } |
|
| 40 |
+ |
|
| 41 |
+ if len(r.buf) == 0 {
|
|
| 42 |
+ return nil |
|
| 43 |
+ } |
|
| 44 |
+ out := r.buf[0] |
|
| 45 |
+ r.buf[0] = nil |
|
| 46 |
+ r.buf = r.buf[1:] |
|
| 47 |
+ return out |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 50 |
+func (r *dirReader) Err() error {
|
|
| 51 |
+ return r.err |
|
| 52 |
+} |
| ... | ... |
@@ -361,7 +361,7 @@ github.com/containerd/containerd/sys |
| 361 | 361 |
github.com/containerd/containerd/sys/reaper |
| 362 | 362 |
github.com/containerd/containerd/tracing |
| 363 | 363 |
github.com/containerd/containerd/version |
| 364 |
-# github.com/containerd/continuity v0.4.2 |
|
| 364 |
+# github.com/containerd/continuity v0.4.3 |
|
| 365 | 365 |
## explicit; go 1.19 |
| 366 | 366 |
github.com/containerd/continuity/devices |
| 367 | 367 |
github.com/containerd/continuity/driver |