MCPcopy Index your code
hub / github.com/devspace-sh/devspace / tarFolder

Method tarFolder

pkg/devspace/sync/tar.go:247–288  ·  view source on GitHub ↗
(target *FileInformation, targetStat os.FileInfo)

Source from the content-addressed store, hash-verified

245}
246
247func (a *Archiver) tarFolder(target *FileInformation, targetStat os.FileInfo) error {
248 filePath := path.Join(a.basePath, target.Name)
249 files, err := os.ReadDir(filePath)
250 if err != nil {
251 // config.Logf("[Upstream] Couldn't read dir %s: %s\n", filepath, err.Error())
252 return nil
253 }
254
255 if len(files) == 0 && target.Name != "" {
256 // check if not excluded
257 if a.ignoreMatcher == nil || !a.ignoreMatcher.RequireFullScan() || !a.ignoreMatcher.Matches(target.Name, true) {
258 // Case empty directory
259 hdr, _ := tar.FileInfoHeader(targetStat, filePath)
260 hdr.Uid = 0
261 hdr.Gid = 0
262 hdr.Mode = fillGo18FileTypeBits(int64(chmodTarEntry(os.FileMode(hdr.Mode))), targetStat)
263 hdr.Name = target.Name
264 if err := a.writer.WriteHeader(hdr); err != nil {
265 return errors.Wrap(err, "tar write header")
266 }
267
268 a.writtenFiles[target.Name] = target
269 }
270 }
271
272 for _, dirEntry := range files {
273 f, err := dirEntry.Info()
274 if err != nil {
275 continue
276 }
277
278 if fsutil.IsRecursiveSymlink(f, path.Join(filePath, f.Name())) {
279 continue
280 }
281
282 if err = a.AddToArchive(path.Join(target.Name, f.Name())); err != nil {
283 return errors.Wrap(err, "recursive tar "+f.Name())
284 }
285 }
286
287 return nil
288}
289
290func (a *Archiver) tarFile(target *FileInformation, targetStat os.FileInfo) error {
291 var err error

Callers 1

AddToArchiveMethod · 0.95

Calls 8

AddToArchiveMethod · 0.95
IsRecursiveSymlinkFunction · 0.92
fillGo18FileTypeBitsFunction · 0.85
chmodTarEntryFunction · 0.85
RequireFullScanMethod · 0.65
MatchesMethod · 0.65
NameMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected