mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Report copy fix (#6264)
* Update process for copying default report templates - Overwrite if the file hash has changed * Cleanup inline code
This commit is contained in:
@ -12,22 +12,12 @@ from django.conf import settings
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
|
||||
|
||||
import InvenTree.helpers
|
||||
import InvenTree.ready
|
||||
|
||||
logger = logging.getLogger('inventree')
|
||||
|
||||
|
||||
def hashFile(filename):
|
||||
"""Calculate the MD5 hash of a file."""
|
||||
md5 = hashlib.md5()
|
||||
|
||||
with open(filename, 'rb') as f:
|
||||
data = f.read()
|
||||
md5.update(data)
|
||||
|
||||
return md5.hexdigest()
|
||||
|
||||
|
||||
class LabelConfig(AppConfig):
|
||||
"""App configuration class for the 'label' app."""
|
||||
|
||||
@ -167,7 +157,9 @@ class LabelConfig(AppConfig):
|
||||
if dst_file.exists():
|
||||
# File already exists - let's see if it is the "same"
|
||||
|
||||
if hashFile(dst_file) != hashFile(src_file): # pragma: no cover
|
||||
if InvenTree.helpers.hash_file(dst_file) != InvenTree.helpers.hash_file(
|
||||
src_file
|
||||
): # pragma: no cover
|
||||
logger.info("Hash differs for '%s'", filename)
|
||||
to_copy = True
|
||||
|
||||
|
Reference in New Issue
Block a user