Fix file deletion skipping
This commit is contained in:
parent
6cac237075
commit
eef7edab49
2 changed files with 12 additions and 6 deletions
|
@ -40,9 +40,10 @@ class TestStreamLayerMerger(unittest.TestCase):
|
||||||
with tarfile.open(fileobj=StringIO(squashed), mode='r:*') as tar:
|
with tarfile.open(fileobj=StringIO(squashed), mode='r:*') as tar:
|
||||||
try:
|
try:
|
||||||
member = tar.getmember(filename)
|
member = tar.getmember(filename)
|
||||||
self.fail('Filename %s found' % filename)
|
except Exception as ex:
|
||||||
except:
|
return
|
||||||
pass
|
|
||||||
|
self.fail('Filename %s found' % filename)
|
||||||
|
|
||||||
def test_single_layer(self):
|
def test_single_layer(self):
|
||||||
tar_layer = self.create_layer(
|
tar_layer = self.create_layer(
|
||||||
|
@ -122,11 +123,11 @@ class TestStreamLayerMerger(unittest.TestCase):
|
||||||
|
|
||||||
def test_deleted_in_lower_layer(self):
|
def test_deleted_in_lower_layer(self):
|
||||||
third_layer = self.create_layer(
|
third_layer = self.create_layer(
|
||||||
another_file = 'bar')
|
deleted_file = 'bar')
|
||||||
|
|
||||||
second_layer = self.create_layer(
|
second_layer = self.create_layer(
|
||||||
some_file = 'foo',
|
some_file = 'foo',
|
||||||
another_file = None,
|
deleted_file = None,
|
||||||
third_file = 'meh')
|
third_file = 'meh')
|
||||||
|
|
||||||
first_layer = self.create_layer(
|
first_layer = self.create_layer(
|
||||||
|
@ -137,7 +138,9 @@ class TestStreamLayerMerger(unittest.TestCase):
|
||||||
self.assertHasFile(squashed, 'some_file', 'foo')
|
self.assertHasFile(squashed, 'some_file', 'foo')
|
||||||
self.assertHasFile(squashed, 'third_file', 'meh')
|
self.assertHasFile(squashed, 'third_file', 'meh')
|
||||||
self.assertHasFile(squashed, 'top_file', 'top')
|
self.assertHasFile(squashed, 'top_file', 'top')
|
||||||
self.assertDoesNotHaveFile(squashed, 'another_file')
|
self.assertDoesNotHaveFile(squashed, 'deleted_file')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -28,4 +28,7 @@ def get_deleted_prefix(filepath):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
dirname = os.path.dirname(filepath)
|
dirname = os.path.dirname(filepath)
|
||||||
|
if not dirname:
|
||||||
|
return deleted_filename
|
||||||
|
|
||||||
return os.path.join('/', dirname, deleted_filename)
|
return os.path.join('/', dirname, deleted_filename)
|
||||||
|
|
Reference in a new issue