Project

Profile

Help

Issue #8295 ยป sync_disk_usage_change.patch

lmjachky, 05/02/2021 01:54 PM

View differences:

pulpcore/plugin/stages/api.py
81 81
            log.debug("%(name)s - next: %(content)s.", {"name": self, "content": content})
82 82
            yield content
83 83

  
84
    async def batches(self, minsize=500):
84
    # the default value for the parameter minsize should be changed
85
    async def batches(self, minsize=50):
85 86
        """
86 87
        Asynchronous iterator yielding batches of :class:`DeclarativeContent` from `self._in_q`.
87 88

  
pulpcore/plugin/stages/artifact_stages.py
1
import os
2

  
1 3
import asyncio
2 4
from collections import defaultdict
3 5
from gettext import gettext as _
......
227 229
            The coroutine for this stage.
228 230
        """
229 231
        async for batch in self.batches():
232
            # TODO: artifacts are saved only here when the minimal size of the batch is reached;
233
            #   otherwise, all the artifacts are saved only when the queue is filled with 500 file
234
            #   units (temporary files)
230 235
            da_to_save = []
236
            tmp_files = []
231 237
            for d_content in batch:
232 238
                for d_artifact in d_content.d_artifacts:
233 239
                    if d_artifact.artifact._state.adding and not d_artifact.deferred_download:
234 240
                        d_artifact.artifact.file = str(d_artifact.artifact.file)
241
                        tmp_files.append(str(d_artifact.artifact.file))
235 242
                        da_to_save.append(d_artifact)
236 243

  
237 244
            if da_to_save:
......
246 253
            for d_content in batch:
247 254
                await self.put(d_content)
248 255

  
256
            # the caller should do the clean-up since temporary files are initialized with the
257
            # parameter delete=False
258
            for path in tmp_files:
259
                os.unlink(path)
249 260

  
250 261
class RemoteArtifactSaver(Stage):
251 262
    """
    (1-1/1)