Skip to content

Commit 81a55e9

Browse files
committed
urlscm: remove downloaded files on ATTIC move
Delete the download directory if the scm-workspace is moved to attic.
1 parent 9328c23 commit 81a55e9

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

pym/bob/builder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,8 @@ async def _cookCheckoutStep(self, checkoutStep, depth):
12091209
os.makedirs(atticPath)
12101210
atticPath = os.path.join(atticPath, atticName)
12111211
os.rename(scmPath, atticPath)
1212+
if scmDir in scmMap:
1213+
scmMap[scmDir].postAttic(prettySrcPath)
12121214
BobState().setAtticDirectoryState(atticPath, scmSpec)
12131215
atticPaths.add(scmPath, atticPath)
12141216
del oldCheckoutState[scmDir]

pym/bob/scm/scm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ def calcLiveBuildId(self, workspacePath):
361361
"""Calculate live build-id from workspace."""
362362
return None
363363

364+
def postAttic(self, workspace):
365+
pass
366+
364367
class ScmAudit(metaclass=ABCMeta):
365368
@classmethod
366369
async def fromDir(cls, workspace, dir, extra):

pym/bob/scm/url.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,11 @@ def __getExtractor(self):
788788
raise ParseError("Invalid extract mode: " + self.__extract)
789789
return extractor
790790

791+
def postAttic(self, workspace):
792+
if self.__separateDownload:
793+
downloadDestination = os.path.abspath(os.path.join(workspace, "..", "download", self.__dir))
794+
if os.path.exists(downloadDestination):
795+
shutil.rmtree(downloadDestination)
791796

792797
class UrlAudit(ScmAudit):
793798

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bobMinimumVersion: "0.17.3.dev82"
1+
bobMinimumVersion: "0.25.1.dev32"

test/black-box/url-scm-switch/run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
. ../../test-lib.sh 2>/dev/null || { echo "Must run in script directory!" ; exit 1 ; }
77
cleanup
88

9+
tempdir=$(mktemp -d)
10+
trap 'rm -rf "${tempdir}"' EXIT
11+
912
url="$(mangle_path "$(realpath file.txt)")"
1013
url2="$(mangle_path "$(realpath file2.txt)")"
1114

15+
tar -cvzf $tempdir/file.tgz file.txt
16+
tar -cvzf $tempdir/file2.tgz file2.txt
17+
1218
# Build and fetch result path
1319
run_bob dev root -DURL="$url"
1420
path=$(run_bob query-path -DURL="$url" -f {src} root)
@@ -36,3 +42,11 @@ run_bob dev root -DURL="$url2"
3642
expect_not_exist "$path/file.txt"
3743
expect_not_exist "$path/canary.txt"
3844
diff -q "$path/file2.txt" file2.txt
45+
46+
cleanup
47+
run_bob dev root -DURL="$tempdir/file.tgz"
48+
expect_exist $path/../download/file.tgz
49+
50+
run_bob dev root -DURL="$tempdir/file2.tgz"
51+
expect_exist $path/../download/file2.tgz
52+
expect_not_exist $path/../download/file.tgz

0 commit comments

Comments
 (0)