Fixed #30599 -- Prevented ManifestFilesMixin.read_manifest() from silencing errors other than FileNotFoundError.
This commit is contained in:
parent
246689452d
commit
955b382600
|
@ -382,7 +382,7 @@ class ManifestFilesMixin(HashedFilesMixin):
|
||||||
try:
|
try:
|
||||||
with self.open(self.manifest_name) as manifest:
|
with self.open(self.manifest_name) as manifest:
|
||||||
return manifest.read().decode()
|
return manifest.read().decode()
|
||||||
except OSError:
|
except FileNotFoundError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def load_manifest(self):
|
def load_manifest(self):
|
||||||
|
|
|
@ -4,6 +4,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles import finders, storage
|
from django.contrib.staticfiles import finders, storage
|
||||||
|
@ -389,6 +390,11 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
|
||||||
storage.staticfiles_storage.manifest_name = 'does.not.exist.json'
|
storage.staticfiles_storage.manifest_name = 'does.not.exist.json'
|
||||||
self.assertIsNone(storage.staticfiles_storage.read_manifest())
|
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):
|
def test_loaded_cache(self):
|
||||||
self.assertNotEqual(storage.staticfiles_storage.hashed_files, {})
|
self.assertNotEqual(storage.staticfiles_storage.hashed_files, {})
|
||||||
manifest_content = storage.staticfiles_storage.read_manifest()
|
manifest_content = storage.staticfiles_storage.read_manifest()
|
||||||
|
|
Loading…
Reference in New Issue