diff --git a/docs/topics/settings.rst b/docs/topics/settings.rst index eb24b834a..439aedc18 100644 --- a/docs/topics/settings.rst +++ b/docs/topics/settings.rst @@ -1122,7 +1122,7 @@ modify this setting in your project, modify :setting:`ITEM_PIPELINES` instead. JOBDIR ------ -Default: ``''`` +Default: ``None`` A string indicating the directory for storing the state of a crawl when :ref:`pausing and resuming crawls `. diff --git a/scrapy/core/scheduler.py b/scrapy/core/scheduler.py index 70b6dc8a1..17c95f1ea 100644 --- a/scrapy/core/scheduler.py +++ b/scrapy/core/scheduler.py @@ -352,7 +352,7 @@ class Scheduler(BaseScheduler): def _dqdir(self, jobdir: Optional[str]) -> Optional[str]: """Return a folder name to keep disk queue state at""" - if jobdir is not None: + if jobdir: dqdir = Path(jobdir, "requests.queue") if not dqdir.exists(): dqdir.mkdir(parents=True) diff --git a/scrapy/settings/default_settings.py b/scrapy/settings/default_settings.py index 7e77884f6..7b6d9f5a8 100644 --- a/scrapy/settings/default_settings.py +++ b/scrapy/settings/default_settings.py @@ -206,6 +206,8 @@ ITEM_PROCESSOR = "scrapy.pipelines.ItemPipelineManager" ITEM_PIPELINES = {} ITEM_PIPELINES_BASE = {} +JOBDIR = None + LOG_ENABLED = True LOG_ENCODING = "utf-8" LOG_FORMATTER = "scrapy.logformatter.LogFormatter" diff --git a/scrapy/utils/job.py b/scrapy/utils/job.py index c49f7d758..e230e4235 100644 --- a/scrapy/utils/job.py +++ b/scrapy/utils/job.py @@ -5,7 +5,9 @@ from scrapy.settings import BaseSettings def job_dir(settings: BaseSettings) -> Optional[str]: - path: str = settings["JOBDIR"] - if path and not Path(path).exists(): + path: Optional[str] = settings["JOBDIR"] + if not path: + return None + if not Path(path).exists(): Path(path).mkdir(parents=True) return path