mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	Paperless will continue to operate with encrypted files, however, all new files will be stored unencrypted.
This commit is contained in:
		
							parent
							
								
									2163015d06
								
							
						
					
					
						commit
						ef15de18a9
					
				@ -208,10 +208,7 @@ class Consumer(LoggingMixin):
 | 
				
			|||||||
        created = file_info.created or date or timezone.make_aware(
 | 
					        created = file_info.created or date or timezone.make_aware(
 | 
				
			||||||
            datetime.datetime.fromtimestamp(stats.st_mtime))
 | 
					            datetime.datetime.fromtimestamp(stats.st_mtime))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if settings.PASSPHRASE:
 | 
					        storage_type = Document.STORAGE_TYPE_UNENCRYPTED
 | 
				
			||||||
            storage_type = Document.STORAGE_TYPE_GPG
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            storage_type = Document.STORAGE_TYPE_UNENCRYPTED
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with open(self.path, "rb") as f:
 | 
					        with open(self.path, "rb") as f:
 | 
				
			||||||
            document = Document.objects.create(
 | 
					            document = Document.objects.create(
 | 
				
			||||||
@ -260,8 +257,4 @@ class Consumer(LoggingMixin):
 | 
				
			|||||||
    def _write(self, document, source, target):
 | 
					    def _write(self, document, source, target):
 | 
				
			||||||
        with open(source, "rb") as read_file:
 | 
					        with open(source, "rb") as read_file:
 | 
				
			||||||
            with open(target, "wb") as write_file:
 | 
					            with open(target, "wb") as write_file:
 | 
				
			||||||
                if document.storage_type == Document.STORAGE_TYPE_UNENCRYPTED:
 | 
					                write_file.write(read_file.read())
 | 
				
			||||||
                    write_file.write(read_file.read())
 | 
					 | 
				
			||||||
                    return
 | 
					 | 
				
			||||||
                self.log("debug", "Encrypting")
 | 
					 | 
				
			||||||
                write_file.write(GnuPG.encrypted(read_file))
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -82,8 +82,6 @@ class Command(Renderable, BaseCommand):
 | 
				
			|||||||
    def _import_files_from_manifest(self):
 | 
					    def _import_files_from_manifest(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        storage_type = Document.STORAGE_TYPE_UNENCRYPTED
 | 
					        storage_type = Document.STORAGE_TYPE_UNENCRYPTED
 | 
				
			||||||
        if settings.PASSPHRASE:
 | 
					 | 
				
			||||||
            storage_type = Document.STORAGE_TYPE_GPG
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for record in self.manifest:
 | 
					        for record in self.manifest:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -105,23 +103,8 @@ class Command(Renderable, BaseCommand):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            create_source_path_directory(document.source_path)
 | 
					            create_source_path_directory(document.source_path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if settings.PASSPHRASE:
 | 
					            print(f"Moving {document_path} to {document.source_path}")
 | 
				
			||||||
 | 
					            shutil.copy(document_path, document.source_path)
 | 
				
			||||||
                with open(document_path, "rb") as unencrypted:
 | 
					            shutil.copy(thumbnail_path, document.thumbnail_path)
 | 
				
			||||||
                    with open(document.source_path, "wb") as encrypted:
 | 
					 | 
				
			||||||
                        print("Encrypting {} and saving it to {}".format(
 | 
					 | 
				
			||||||
                            doc_file, document.source_path))
 | 
					 | 
				
			||||||
                        encrypted.write(GnuPG.encrypted(unencrypted))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                with open(thumbnail_path, "rb") as unencrypted:
 | 
					 | 
				
			||||||
                    with open(document.thumbnail_path, "wb") as encrypted:
 | 
					 | 
				
			||||||
                        print("Encrypting {} and saving it to {}".format(
 | 
					 | 
				
			||||||
                            thumb_file, document.thumbnail_path))
 | 
					 | 
				
			||||||
                        encrypted.write(GnuPG.encrypted(unencrypted))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            else:
 | 
					 | 
				
			||||||
                print(f"Moving {document_path} to {document.source_path}")
 | 
					 | 
				
			||||||
                shutil.copy(document_path, document.source_path)
 | 
					 | 
				
			||||||
                shutil.copy(thumbnail_path, document.thumbnail_path)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            document.save()
 | 
					            document.save()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user