2
0
Эх сурвалжийг харах

Add info about VerifyPrecompiledFiles to the errors.

Martijn Laan 3 сар өмнө
parent
commit
9e1b67740b

+ 7 - 3
Projects/Src/Compiler.HelperFunc.pas

@@ -176,9 +176,13 @@ begin
   Result := TMemoryStream.Create;
   try
     var FS: TFileStream;
-    if CheckTrust then
-      FS := CheckFileTrust(Filename, [cftoKeepOpen])
-    else
+    if CheckTrust then begin
+      try
+        FS := CheckFileTrust(Filename, [cftoKeepOpen])
+      except
+        raise Exception.CreateFmt(SCompilerCheckPrecompiledFileTrustError, [GetExceptMessage]);
+      end;
+    end else
       FS := nil;
     try
       { Why not use TMemoryStream.LoadFromFile here?

+ 1 - 0
Projects/Src/Compiler.Messages.pas

@@ -102,6 +102,7 @@ const
   SCompilerMustUseDiskSpanning = 'Disk spanning must be enabled in order to create an installation larger than %d bytes in size';
   SCompilerCompileCodeError = 'An error occurred while trying to compile the [Code] section:' + SNewLine2 + '%s';
   SCompilerFunctionFailedWithCode = '%s failed. Error %d: %s';
+  SCompilerCheckPrecompiledFileTrustError = '%s' + SNewLine2 + 'To disable this verification, set [Setup] section directive "VerifyPrecompiledFiles" to "no". Before proceding, ensure that the file is neither corrupted nor has been tampered with.';
 
   { [Setup] }
   SCompilerUnknownDirective = 'Unrecognized [%s] section directive "%s"';

+ 2 - 1
Projects/Src/Compiler.SetupCompiler.pas

@@ -7187,8 +7187,9 @@ var
       try
         CheckFileTrust(SourceFile, CheckFileTrustOptions);
       except
-        AbortCompileFmt(SCompilerCopyError3a, [SourceFile, DestFile,
+        const Msg = Format(SCompilerCopyError3a, [SourceFile, DestFile,
           GetExceptMessage]);
+        AbortCompileFmt(SCompilerCheckPrecompiledFileTrustError, [Msg]);
       end;
     end;
 

+ 2 - 2
Projects/Src/Compression.LZMACompressor.pas

@@ -146,7 +146,7 @@ type
 implementation
 
 uses
-  Classes, TrustFunc, Shared.CommonFunc;
+  Classes, TrustFunc, Shared.CommonFunc, Compiler.Messages;
 
 const
   ISLZMA_EXE_VERSION = 102;
@@ -779,7 +779,7 @@ begin
       try
         F := CheckFileTrust(FExeFilename, [cftoKeepOpen]);
       except
-        LZMAInternalError(GetExceptMessage);
+        LZMAInternalError(Format(SCompilerCheckPrecompiledFileTrustError, [GetExceptMessage]));
       end;
     end;
     try