Skip to content

Commit b75a3d6

Browse files
authored
Merge pull request #804 from crazywhalecc/feat/del-download-type
Allow deleting pre-built or source only for del-download
2 parents 1a42963 + f6d2515 commit b75a3d6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/SPC/command/DeleteDownloadCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public function configure(): void
2222
{
2323
$this->addArgument('sources', InputArgument::REQUIRED, 'The sources/packages will be deleted, comma separated');
2424
$this->addOption('all', 'A', null, 'Delete all downloaded and locked sources/packages');
25+
$this->addOption('pre-built-only', 'W', null, 'Delete only pre-built sources/packages, not the original ones');
26+
$this->addOption('source-only', 'S', null, 'Delete only sources, not the pre-built packages');
2527
}
2628

2729
public function initialize(InputInterface $input, OutputInterface $output): void
@@ -51,10 +53,11 @@ public function handle(): int
5153
$deleted_sources = [];
5254
foreach ($chosen_sources as $source) {
5355
$source = trim($source);
54-
foreach ([$source, Downloader::getPreBuiltLockName($source)] as $name) {
55-
if (LockFile::get($name)) {
56-
$deleted_sources[] = $name;
57-
}
56+
if (LockFile::get($source) && !$this->getOption('pre-built-only')) {
57+
$deleted_sources[] = $source;
58+
}
59+
if (LockFile::get(Downloader::getPreBuiltLockName($source)) && !$this->getOption('source-only')) {
60+
$deleted_sources[] = Downloader::getPreBuiltLockName($source);
5861
}
5962
}
6063

0 commit comments

Comments
 (0)