Commit 52bad5f8 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Avoid running out of file descriptors when backing up many objects in the...

Avoid running out of file descriptors when backing up many objects in the trash upon bt5 installation.

Before, when installing a bt5 whose format has changed, many subobjects may
end up being backup up, but it keeps one FD per subobject, thus easily
reaching the limit of 1024 FDs (as given by ulimit -Sn/-Hn).

This is a followup of b71e5a73 specific to TrashTool as that commit seems to
only fix the issue when TrashTool is not used.
parent ce5d18cb
...@@ -37,6 +37,7 @@ from Products.ERP5 import _dtmldir ...@@ -37,6 +37,7 @@ from Products.ERP5 import _dtmldir
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
from DateTime import DateTime from DateTime import DateTime
from Acquisition import aq_base from Acquisition import aq_base
from cStringIO import StringIO
class TrashTool(BaseTool): class TrashTool(BaseTool):
""" """
...@@ -144,10 +145,11 @@ class TrashTool(BaseTool): ...@@ -144,10 +145,11 @@ class TrashTool(BaseTool):
object_path = container_path + [object_id] object_path = container_path + [object_id]
obj = self.unrestrictedTraverse(object_path) obj = self.unrestrictedTraverse(object_path)
if obj is not None: if obj is not None:
for subobject_id in list(obj.objectIds()): for subobject_id in obj.objectIds():
subobject = obj.unrestrictedTraverse(subobject_id) subobject = obj[subobject_id]
subobject_copy = subobject._p_jar.exportFile(subobject._p_oid) subobjects_dict[subobject_id] = subobject._p_jar.exportFile(
subobjects_dict[subobject_id] = subobject_copy subobject._p_oid, StringIO())
if save: # remove subobjecs from backup object if save: # remove subobjecs from backup object
obj._delObject(subobject_id) obj._delObject(subobject_id)
if subobject_id in obj.objectIds(): if subobject_id in obj.objectIds():
......
Markdown is supported
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