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

Method AddToArchive

pkg/devspace/sync/tar.go:215–245  ·  view source on GitHub ↗

AddToArchive adds a new path to the archive

(relativePath string)

Source from the content-addressed store, hash-verified

213
214// AddToArchive adds a new path to the archive
215func (a *Archiver) AddToArchive(relativePath string) error {
216 absFilepath := path.Join(a.basePath, relativePath)
217 if a.writtenFiles[relativePath] != nil {
218 return nil
219 }
220
221 // We skip files that are suddenly not there anymore
222 stat, err := os.Stat(absFilepath)
223 if err != nil {
224 // config.Logf("[Upstream] Couldn't stat file %s: %s\n", absFilepath, err.Error())
225 return nil
226 }
227
228 // Exclude files on the exclude list if it does not have a negate pattern, otherwise we will check below
229 if a.ignoreMatcher != nil && !a.ignoreMatcher.RequireFullScan() && a.ignoreMatcher.Matches(relativePath, stat.IsDir()) {
230 return nil
231 }
232
233 fileInformation := createFileInformationFromStat(relativePath, stat)
234 if stat.IsDir() {
235 // Recursively tar folder
236 return a.tarFolder(fileInformation, stat)
237 }
238
239 // exclude file?
240 if a.ignoreMatcher == nil || !a.ignoreMatcher.RequireFullScan() || !a.ignoreMatcher.Matches(relativePath, false) {
241 return a.tarFile(fileInformation, stat)
242 }
243
244 return nil
245}
246
247func (a *Archiver) tarFolder(target *FileInformation, targetStat os.FileInfo) error {
248 filePath := path.Join(a.basePath, target.Name)

Callers 3

tarFolderMethod · 0.95
compressMethod · 0.95
writeTarFunction · 0.80

Calls 6

tarFolderMethod · 0.95
tarFileMethod · 0.95
RequireFullScanMethod · 0.65
MatchesMethod · 0.65
IsDirMethod · 0.45

Tested by

no test coverage detected