Fixed #30599 -- Prevented ManifestFilesMixin.read_manifest() from silencing errors other than FileNotFoundError.

This commit is contained in:
zeyneloz 2019-08-01 16:42:58 +02:00 committed by Mariusz Felisiak
parent 246689452d
commit 955b382600
2 changed files with 7 additions and 1 deletions

View File

@ -382,7 +382,7 @@ class ManifestFilesMixin(HashedFilesMixin):
try:
with self.open(self.manifest_name) as manifest:
return manifest.read().decode()
except OSError:
except FileNotFoundError:
return None
def load_manifest(self):

View File

@ -4,6 +4,7 @@ import sys
import tempfile
import unittest
from io import StringIO
from unittest import mock
from django.conf import settings
from django.contrib.staticfiles import finders, storage
@ -389,6 +390,11 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
storage.staticfiles_storage.manifest_name = 'does.not.exist.json'
self.assertIsNone(storage.staticfiles_storage.read_manifest())
def test_manifest_does_not_ignore_permission_error(self):
with mock.patch('builtins.open', side_effect=PermissionError):
with self.assertRaises(PermissionError):
storage.staticfiles_storage.read_manifest()
def test_loaded_cache(self):
self.assertNotEqual(storage.staticfiles_storage.hashed_files, {})
manifest_content = storage.staticfiles_storage.read_manifest()