Nits.
This commit is contained in:
parent
92d02ce4f5
commit
b48b542c06
1 changed files with 23 additions and 10 deletions
|
@ -35,6 +35,7 @@ namespace ARMeilleure.Translation.AOT
|
||||||
public static string TitleId { get; private set; }
|
public static string TitleId { get; private set; }
|
||||||
|
|
||||||
public static bool Enabled { get; private set; }
|
public static bool Enabled { get; private set; }
|
||||||
|
public static bool ReadOnlyMode { get; private set; }
|
||||||
|
|
||||||
static Aot()
|
static Aot()
|
||||||
{
|
{
|
||||||
|
@ -52,6 +53,7 @@ namespace ARMeilleure.Translation.AOT
|
||||||
TitleId = String.Empty;
|
TitleId = String.Empty;
|
||||||
|
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
|
ReadOnlyMode = true;
|
||||||
|
|
||||||
_infosStream = new MemoryStream();
|
_infosStream = new MemoryStream();
|
||||||
_codesStream = new MemoryStream();
|
_codesStream = new MemoryStream();
|
||||||
|
@ -75,6 +77,7 @@ namespace ARMeilleure.Translation.AOT
|
||||||
}
|
}
|
||||||
|
|
||||||
Enabled = enabled;
|
Enabled = enabled;
|
||||||
|
ReadOnlyMode = readOnlyMode;
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +100,8 @@ namespace ARMeilleure.Translation.AOT
|
||||||
{
|
{
|
||||||
using (FileStream compressedCacheStream = new FileStream(cachePath, FileMode.Open))
|
using (FileStream compressedCacheStream = new FileStream(cachePath, FileMode.Open))
|
||||||
{
|
{
|
||||||
|
DeflateStream deflateStream = new DeflateStream(compressedCacheStream, CompressionMode.Decompress, true);
|
||||||
|
|
||||||
MemoryStream cacheStream = new MemoryStream();
|
MemoryStream cacheStream = new MemoryStream();
|
||||||
|
|
||||||
MD5 md5 = MD5.Create();
|
MD5 md5 = MD5.Create();
|
||||||
|
@ -105,7 +110,7 @@ namespace ARMeilleure.Translation.AOT
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (DeflateStream deflateStream = new DeflateStream(compressedCacheStream, CompressionMode.Decompress, true))
|
using (deflateStream)
|
||||||
{
|
{
|
||||||
deflateStream.CopyTo(cacheStream);
|
deflateStream.CopyTo(cacheStream);
|
||||||
}
|
}
|
||||||
|
@ -150,22 +155,22 @@ namespace ARMeilleure.Translation.AOT
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
compressedCacheStream.SetLength(0L);
|
InvalidateCompressedCacheStream(compressedCacheStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
compressedCacheStream.SetLength(0L);
|
InvalidateCompressedCacheStream(compressedCacheStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
compressedCacheStream.SetLength(0L);
|
InvalidateCompressedCacheStream(compressedCacheStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
compressedCacheStream.SetLength(0L);
|
InvalidateCompressedCacheStream(compressedCacheStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
md5.Dispose();
|
md5.Dispose();
|
||||||
|
@ -208,6 +213,14 @@ namespace ARMeilleure.Translation.AOT
|
||||||
headerReader.Dispose();
|
headerReader.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void InvalidateCompressedCacheStream(FileStream compressedCacheStream)
|
||||||
|
{
|
||||||
|
if (!ReadOnlyMode)
|
||||||
|
{
|
||||||
|
compressedCacheStream.SetLength(0L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void MergeAndSave(Object source, ElapsedEventArgs e)
|
private static void MergeAndSave(Object source, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
string cachePath = Path.Combine(WorkPath, TitleId);
|
string cachePath = Path.Combine(WorkPath, TitleId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue