diff --git a/ConfigApp/WorkshopInstallHandler.cs b/ConfigApp/WorkshopInstallHandler.cs index 39b5ab37b..34abaf709 100644 --- a/ConfigApp/WorkshopInstallHandler.cs +++ b/ConfigApp/WorkshopInstallHandler.cs @@ -115,9 +115,12 @@ string getFileSha256(byte[] buffer) fileContent = File.ReadAllBytes(targetCacheDirName); var cachedFileHash = getFileSha256(fileContent); - isFileCached = cachedFileHash == m_SubmissionItem.Sha256; - // Cached files are always compressed - isFileCompressed = true; + if (cachedFileHash == m_SubmissionItem.Sha256) + { + isFileCached = true; + // Cached files are always compressed + isFileCompressed = true; + } } if (!isFileCached) @@ -151,6 +154,25 @@ string getFileSha256(byte[] buffer) return; } + try + { + Directory.CreateDirectory("workshopcache"); + + // Recompress if necessary for caching + var cachedFileContent = fileContent; + if (!isFileCompressed) + { + var compressor = new Compressor(10); + cachedFileContent = compressor.Wrap(fileContent).ToArray(); + } + + File.WriteAllBytes(targetCacheDirName, cachedFileContent); + } + catch (Exception) + { + // Doesn't matter if this fails, it's just a cached file anyways + } + var fileStream = new MemoryStream(fileContent); if (isFileCompressed) { @@ -234,24 +256,6 @@ string getFileSha256(byte[] buffer) m_SubmissionItem.InstallState = WorkshopSubmissionItem.SubmissionInstallState.Installed; SystemSounds.Beep.Play(); - - try - { - Directory.CreateDirectory("workshopcache"); - - // Recompress if necessary for caching - if (!isFileCompressed) - { - var compressor = new Compressor(10); - fileContent = compressor.Wrap(fileContent).ToArray(); - } - - File.WriteAllBytes(targetCacheDirName, fileContent); - } - catch (Exception) - { - // Doesn't matter if this fails, it's just a cached file anyways - } } catch (HttpRequestException) {