Commit bf48992b authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Minor improvement to package from tar command

parent 6c44fde3
Pipeline #47995 canceled with stages
in 4 seconds
......@@ -345,11 +345,17 @@ class Package(Document):
self.package.size += tarinfo.size
self.package.files += 1
def close(self) -> None:
def close(self, all_packages: bool = False) -> None:
self.package_file.close()
self.package.next_offset = last_offset
self.package.save()
if all_packages:
packages = Package.objects(upload_id=self.package.upload_id).count()
Package._get_collection().update_many(
dict(upload_id=self.package.upload_id), {'$set': dict(packages=packages)})
current_upload = None
# the package of the current directory, might be reused for other directories,
# if not too big
......@@ -373,12 +379,7 @@ class Package(Document):
package.close()
if current_package is not None:
current_package.close()
if current_upload is not None:
packages = Package.objects(upload_id=current_upload).count()
Package._get_collection().update_many(
dict(upload_id=current_upload), {'$set': dict(packages=packages)})
current_package.close(True)
current_upload = upload
print('new upload %s' % current_upload)
......@@ -477,11 +478,14 @@ class Package(Document):
pass
print('The smallest offset of an open package was %d' % smallest_offset)
else:
for package in list(directories.values()) + [current_package, last_package]:
if package is not None and package != current_package:
package.close()
if current_package is not None:
current_package.close(True)
finally:
tf.close()
if current_package is not None:
current_package.close()
@classmethod
def get_packages(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment