RemoveFiles removes files that were created by Publish It can remove prefix fully, and part of pool (for specific component)
(publishedStorageProvider aptly.PublishedStorageProvider, removePrefix bool, removePoolComponents []string, progress aptly.Progress)
| 1260 | // |
| 1261 | // It can remove prefix fully, and part of pool (for specific component) |
| 1262 | func (p *PublishedRepo) RemoveFiles(publishedStorageProvider aptly.PublishedStorageProvider, removePrefix bool, |
| 1263 | removePoolComponents []string, progress aptly.Progress) error { |
| 1264 | publishedStorage, err := publishedStorageProvider.GetPublishedStorage(p.Storage) |
| 1265 | if err != nil { |
| 1266 | return err |
| 1267 | } |
| 1268 | |
| 1269 | // I. Easy: remove whole prefix (meta+packages) |
| 1270 | if removePrefix { |
| 1271 | err := publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "dists"), progress) |
| 1272 | if err != nil { |
| 1273 | return err |
| 1274 | } |
| 1275 | |
| 1276 | return publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "pool"), progress) |
| 1277 | } |
| 1278 | |
| 1279 | // II. Medium: remove metadata, it can't be shared as prefix/distribution as unique |
| 1280 | err = publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "dists", p.Distribution), progress) |
| 1281 | if err != nil { |
| 1282 | return err |
| 1283 | } |
| 1284 | |
| 1285 | // III. Complex: there are no other publishes with the same prefix + component |
| 1286 | for _, component := range removePoolComponents { |
| 1287 | err = publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "pool", component), progress) |
| 1288 | if err != nil { |
| 1289 | return err |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | return nil |
| 1294 | } |
| 1295 | |
| 1296 | // PublishedRepoCollection does listing, updating/adding/deleting of PublishedRepos |
| 1297 | type PublishedRepoCollection struct { |