Skip to content

Commit 4740be0

Browse files
authored
Fix source unpacking (#154)
1 parent 8606d11 commit 4740be0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
25.3.1
2+
* Create target folder before extracting tar files
3+
* Work around Debian sometimes keeping around files
4+
15
25.3.0
26
* Unpack or copy over additional folders besides __root__ in layer-update
37
* Allow switching over to using tars for layer source without changing the

perfact/zodbsync/subcommand.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,27 @@ def unpack_source(src, tgt):
111111
unpacked, both removing superfluous files in the target.
112112
"""
113113
targetitems = []
114-
for entry in os.listdir(src):
114+
srcitems = os.listdir(src)
115+
for entry in srcitems:
115116
if entry.startswith('.'):
116117
continue
117118
path = f'{src}/{entry}'
118119
if os.path.isdir(path):
119120
# p.e. __root__ or __schema__ as folders
121+
# Sometimes, there might be some residual folder with .dpkg-new
122+
# files or similar, even though this is now supplied as file.
123+
other = [other for other in srcitems
124+
if other.startswith(entry) and other != entry]
125+
if other:
126+
continue
120127
targetitems.append(entry)
121128
cmd = ['rsync', '-a', '--delete-during',
122129
f'{path}/', f'{tgt}/{entry}/']
123130
else:
124131
# p.e. __root__.tar.gz -> Unpack to __root__/
125132
basename = entry.split('.')[0]
126133
targetitems.append(basename)
134+
os.makedirs(f'{tgt}/{basename}', exist_ok=True)
127135
cmd = ['tar', 'xf', path, '-C', f'{tgt}/{basename}/',
128136
'--recursive-unlink']
129137
subprocess.run(cmd, check=True)

0 commit comments

Comments
 (0)