@ -463,7 +463,7 @@ namespace IPA.Updating.ModSaber
var data = stream . GetBuffer ( ) ;
var data = stream . GetBuffer ( ) ;
SHA1 sha = new SHA1CryptoServiceProvider ( ) ;
SHA1 sha = new SHA1CryptoServiceProvider ( ) ;
var hash = sha . ComputeHash ( data ) ;
var hash = sha . ComputeHash ( data ) ;
if ( ! LoneFunction s. UnsafeCompare ( hash , fileInfo . Hash ) )
if ( ! Util s. UnsafeCompare ( hash , fileInfo . Hash ) )
throw new Exception ( "The hash for the file doesn't match what is defined" ) ;
throw new Exception ( "The hash for the file doesn't match what is defined" ) ;
var targetDir = Path . Combine ( BeatSaber . InstallPath , "IPA" , Path . GetRandomFileName ( ) + "_Pending" ) ;
var targetDir = Path . Combine ( BeatSaber . InstallPath , "IPA" , Path . GetRandomFileName ( ) + "_Pending" ) ;
@ -499,7 +499,7 @@ namespace IPA.Updating.ModSaber
try
try
{
{
if ( ! LoneFunction s. UnsafeCompare ( fileHash , fileInfo . FileHashes [ entry . FileName ] ) )
if ( ! Util s. UnsafeCompare ( fileHash , fileInfo . FileHashes [ entry . FileName ] ) )
throw new Exception ( "The hash for the file doesn't match what is defined" ) ;
throw new Exception ( "The hash for the file doesn't match what is defined" ) ;
}
}
catch ( KeyNotFoundException )
catch ( KeyNotFoundException )
@ -511,7 +511,7 @@ namespace IPA.Updating.ModSaber
FileInfo targetFile = new FileInfo ( Path . Combine ( targetDir , entry . FileName ) ) ;
FileInfo targetFile = new FileInfo ( Path . Combine ( targetDir , entry . FileName ) ) ;
Directory . CreateDirectory ( targetFile . DirectoryName ? ? throw new InvalidOperationException ( ) ) ;
Directory . CreateDirectory ( targetFile . DirectoryName ? ? throw new InvalidOperationException ( ) ) ;
if ( LoneFunction s. GetRelativePath ( targetFile . FullName , targetDir ) = = LoneFunction s. GetRelativePath ( item . LocalPluginMeta ? . Metadata . File . FullName , BeatSaber . InstallPath ) )
if ( Util s. GetRelativePath ( targetFile . FullName , targetDir ) = = Util s. GetRelativePath ( item . LocalPluginMeta ? . Metadata . File . FullName , BeatSaber . InstallPath ) )
shouldDeleteOldFile = false ; // overwriting old file, no need to delete
shouldDeleteOldFile = false ; // overwriting old file, no need to delete
/ * if ( targetFile . Exists )
/ * if ( targetFile . Exists )
@ -530,7 +530,7 @@ namespace IPA.Updating.ModSaber
}
}
if ( shouldDeleteOldFile & & item . LocalPluginMeta ! = null )
if ( shouldDeleteOldFile & & item . LocalPluginMeta ! = null )
File . AppendAllLines ( Path . Combine ( targetDir , SpecialDeletionsFile ) , new [ ] { LoneFunction s. GetRelativePath ( item . LocalPluginMeta ? . Metadata . File . FullName , BeatSaber . InstallPath ) } ) ;
File . AppendAllLines ( Path . Combine ( targetDir , SpecialDeletionsFile ) , new [ ] { Util s. GetRelativePath ( item . LocalPluginMeta ? . Metadata . File . FullName , BeatSaber . InstallPath ) } ) ;
}
}
catch ( Exception )
catch ( Exception )
{ // something failed; restore
{ // something failed; restore
@ -545,7 +545,7 @@ namespace IPA.Updating.ModSaber
if ( item . LocalPluginMeta ? . Plugin is SelfPlugin )
if ( item . LocalPluginMeta ? . Plugin is SelfPlugin )
{ // currently updating self, so copy to working dir and update
{ // currently updating self, so copy to working dir and update
LoneFunction s. CopyAll ( new DirectoryInfo ( targetDir ) , new DirectoryInfo ( BeatSaber . InstallPath ) ) ;
Util s. CopyAll ( new DirectoryInfo ( targetDir ) , new DirectoryInfo ( BeatSaber . InstallPath ) ) ;
if ( File . Exists ( Path . Combine ( BeatSaber . InstallPath , SpecialDeletionsFile ) ) ) File . Delete ( Path . Combine ( BeatSaber . InstallPath , SpecialDeletionsFile ) ) ;
if ( File . Exists ( Path . Combine ( BeatSaber . InstallPath , SpecialDeletionsFile ) ) ) File . Delete ( Path . Combine ( BeatSaber . InstallPath , SpecialDeletionsFile ) ) ;
Process . Start ( new ProcessStartInfo
Process . Start ( new ProcessStartInfo
{
{
@ -555,7 +555,7 @@ namespace IPA.Updating.ModSaber
} ) ;
} ) ;
}
}
else
else
LoneFunction s. CopyAll ( new DirectoryInfo ( targetDir ) , new DirectoryInfo ( eventualOutput ) , SpecialDeletionsFile ) ;
Util s. CopyAll ( new DirectoryInfo ( targetDir ) , new DirectoryInfo ( eventualOutput ) , SpecialDeletionsFile ) ;
Directory . Delete ( targetDir , true ) ; // delete extraction site
Directory . Delete ( targetDir , true ) ; // delete extraction site
Logger . updater . Debug ( "Extractor exited" ) ;
Logger . updater . Debug ( "Extractor exited" ) ;