Scrapy, a fast high-level web crawling & scraping framework for Python.
Add a warning/error in case of incorrect gcs permissions (#4508)
Michał Panek628c4a531914
diff --git a/scrapy/pipelines/files.py b/scrapy/pipelines/files.pyindex ae365db5b..a9066986b 100644--- a/scrapy/pipelines/files.py+++ b/scrapy/pipelines/files.py@@ -230,6 +230,20 @@ class GCSFilesStore:bucket, prefix = uri[5:].split('/', 1)self.bucket = client.bucket(bucket)self.prefix = prefix+ permissions = self.bucket.test_iam_permissions(+ ['storage.objects.get', 'storage.objects.create']+ )+ if 'storage.objects.get' not in permissions:+ logger.warning(+ "No 'storage.objects.get' permission for GSC bucket %(bucket)s. "+ "Checking if files are up to date will be impossible. Files will be downloaded every time.",+ {'bucket': bucket}+ )+ if 'storage.objects.create' not in permissions:+ logger.error(+ "No 'storage.objects.create' permission for GSC bucket %(bucket)s. Saving files will be impossible!",+ {'bucket': bucket}+ )def stat_file(self, path, info):def _onsuccess(blob):