| 171 | } |
| 172 | |
| 173 | func recursiveTar(basePath, relativePath string, writtenFiles map[string]bool, tw *tar.Writer, skipFolderContents bool) error { |
| 174 | absFilepath := path.Join(basePath, relativePath) |
| 175 | if _, ok := writtenFiles[relativePath]; ok { |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // We skip files that are suddenly not there anymore |
| 180 | stat, err := os.Stat(absFilepath) |
| 181 | if err != nil { |
| 182 | // File is suddenly not here anymore is ignored |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | fileInformation := createFileInformationFromStat(relativePath, stat) |
| 187 | if stat.IsDir() { |
| 188 | // Recursively tar folder |
| 189 | return tarFolder(basePath, fileInformation, writtenFiles, stat, tw, skipFolderContents) |
| 190 | } |
| 191 | |
| 192 | return tarFile(basePath, fileInformation, writtenFiles, stat, tw) |
| 193 | } |
| 194 | |
| 195 | func tarFolder(basePath string, fileInformation *fileInformation, writtenFiles map[string]bool, stat os.FileInfo, tw *tar.Writer, skipContents bool) error { |
| 196 | filepath := path.Join(basePath, fileInformation.Name) |