mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Add config variable for update check
This commit is contained in:
		@@ -764,3 +764,13 @@ PAPERLESS_OCR_LANGUAGES=<list>
 | 
				
			|||||||
        PAPERLESS_OCR_LANGUAGE=tur
 | 
					        PAPERLESS_OCR_LANGUAGE=tur
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Defaults to none, which does not install any additional languages.
 | 
					    Defaults to none, which does not install any additional languages.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PAPERLESS_ENABLE_UPDATE_CHECK=<bool>
 | 
				
			||||||
 | 
					    Enabling this option enables the check for available updates, which works by
 | 
				
			||||||
 | 
					    loading the version file of the public repository for this project on Github e.g.
 | 
				
			||||||
 | 
					    https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/src/paperless/version.py
 | 
				
			||||||
 | 
					    to determine whether a new version is available. Actual updating of the app must be done manually.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    No tracking data is collected by the app in any way.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Defaults to true.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,6 +67,7 @@
 | 
				
			|||||||
#PAPERLESS_FILENAME_PARSE_TRANSFORMS=[]
 | 
					#PAPERLESS_FILENAME_PARSE_TRANSFORMS=[]
 | 
				
			||||||
#PAPERLESS_THUMBNAIL_FONT_NAME=
 | 
					#PAPERLESS_THUMBNAIL_FONT_NAME=
 | 
				
			||||||
#PAPERLESS_IGNORE_DATES=
 | 
					#PAPERLESS_IGNORE_DATES=
 | 
				
			||||||
 | 
					#PAPERLESS_ENABLE_UPDATE_CHECK=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Tika settings
 | 
					# Tika settings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -674,20 +674,25 @@ class BulkDownloadView(GenericAPIView):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class RemoteVersionView(GenericAPIView):
 | 
					class RemoteVersionView(GenericAPIView):
 | 
				
			||||||
    def get(self, request, format=None):
 | 
					    def get(self, request, format=None):
 | 
				
			||||||
 | 
					        remote_version = "0.0.0"
 | 
				
			||||||
 | 
					        is_greater = False
 | 
				
			||||||
 | 
					        if settings.ENABLE_UPDATE_CHECK:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                with urllib.request.urlopen(
 | 
					                with urllib.request.urlopen(
 | 
				
			||||||
                "https://raw.githubusercontent.com/paperless-ngx/paperless-ngx"
 | 
					                    "https://raw.githubusercontent.com/paperless-ngx"
 | 
				
			||||||
                + "/main/src/paperless/version.py",
 | 
					                    + "/paperless-ngx/main/src/paperless/version.py",
 | 
				
			||||||
                ) as response:
 | 
					                ) as response:
 | 
				
			||||||
                    remote = response.read().decode("utf-8")
 | 
					                    remote = response.read().decode("utf-8")
 | 
				
			||||||
                match = re.search("(\\d+, \\d+, \\d+)", remote)
 | 
					                match = re.search("(\\d+, \\d+, \\d+)", remote)
 | 
				
			||||||
                if match:
 | 
					                if match:
 | 
				
			||||||
                    remote_version = ".".join(match[0].split(", "))
 | 
					                    remote_version = ".".join(match[0].split(", "))
 | 
				
			||||||
            except urllib.error.URLError:
 | 
					            except urllib.error.URLError:
 | 
				
			||||||
            remote_version = "0.0.0"
 | 
					                logger.debug("An error occured checking for available updates")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            current_version = ".".join([str(_) for _ in version.__version__[:3]])
 | 
					            current_version = ".".join([str(_) for _ in version.__version__[:3]])
 | 
				
			||||||
        is_greater = packaging_version.parse(remote_version) > packaging_version.parse(
 | 
					            is_greater = packaging_version.parse(
 | 
				
			||||||
 | 
					                remote_version,
 | 
				
			||||||
 | 
					            ) > packaging_version.parse(
 | 
				
			||||||
                current_version,
 | 
					                current_version,
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -566,3 +566,5 @@ if os.getenv("PAPERLESS_IGNORE_DATES", ""):
 | 
				
			|||||||
        d = dateparser.parse(s)
 | 
					        d = dateparser.parse(s)
 | 
				
			||||||
        if d:
 | 
					        if d:
 | 
				
			||||||
            IGNORE_DATES.add(d.date())
 | 
					            IGNORE_DATES.add(d.date())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENABLE_UPDATE_CHECK = __get_boolean("PAPERLESS_ENABLE_UPDATE_CHECK", "true")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user