mirror of
https://github.com/claunia/osrepodbmgr.git
synced 2025-12-16 19:14:25 +00:00
Added some performance counters.
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
2017-05-19 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
|
* SQLite.cs:
|
||||||
|
* Workers/Files.cs:
|
||||||
|
* Workers/Database.cs:
|
||||||
|
* Workers/VirusTotal.cs:
|
||||||
|
* Workers/Compression.cs:
|
||||||
|
* Workers/DiscImageChef.cs:
|
||||||
|
Added some performance counters.
|
||||||
|
|
||||||
2017-05-19 Natalia Portillo <claunia@claunia.com>
|
2017-05-19 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
* Workers/VirusTotal.cs:
|
* Workers/VirusTotal.cs:
|
||||||
|
|||||||
@@ -96,7 +96,9 @@ namespace osrepodbmgr.Core
|
|||||||
SQLiteCommand dbCmd = dbCon.CreateCommand();
|
SQLiteCommand dbCmd = dbCon.CreateCommand();
|
||||||
string sql;
|
string sql;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
Console.WriteLine("Creating osrepodbmgr table");
|
Console.WriteLine("Creating osrepodbmgr table");
|
||||||
|
#endif
|
||||||
|
|
||||||
sql = "CREATE TABLE osrepodbmgr ( version INTEGER, name TEXT )";
|
sql = "CREATE TABLE osrepodbmgr ( version INTEGER, name TEXT )";
|
||||||
dbCmd.CommandText = sql;
|
dbCmd.CommandText = sql;
|
||||||
@@ -106,11 +108,15 @@ namespace osrepodbmgr.Core
|
|||||||
dbCmd.CommandText = sql;
|
dbCmd.CommandText = sql;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
Console.WriteLine("Creating oses table");
|
Console.WriteLine("Creating oses table");
|
||||||
|
#endif
|
||||||
dbCmd.CommandText = Schema.OSesTableSql;
|
dbCmd.CommandText = Schema.OSesTableSql;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
Console.WriteLine("Creating files table");
|
Console.WriteLine("Creating files table");
|
||||||
|
#endif
|
||||||
dbCmd.CommandText = Schema.FilesTableSql;
|
dbCmd.CommandText = Schema.FilesTableSql;
|
||||||
dbCmd.ExecuteNonQuery();
|
dbCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
|||||||
@@ -188,6 +188,9 @@ namespace osrepodbmgr.Core
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(KeyValuePair<string, DBOSFile> file in Context.hashes)
|
foreach(KeyValuePair<string, DBOSFile> file in Context.hashes)
|
||||||
{
|
{
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
@@ -251,6 +254,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CompressFiles(): Took {0} seconds to compress files", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Context.metadata != null)
|
if(Context.metadata != null)
|
||||||
{
|
{
|
||||||
@@ -319,6 +326,9 @@ namespace osrepodbmgr.Core
|
|||||||
string lsarfilename = unarfilename.Replace("unar", "lsar");
|
string lsarfilename = unarfilename.Replace("unar", "lsar");
|
||||||
string lsarPath = Path.Combine(unarFolder, lsarfilename + extension);
|
string lsarPath = Path.Combine(unarFolder, lsarfilename + extension);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
Process lsarProcess = new Process();
|
Process lsarProcess = new Process();
|
||||||
lsarProcess.StartInfo.FileName = lsarPath;
|
lsarProcess.StartInfo.FileName = lsarPath;
|
||||||
lsarProcess.StartInfo.CreateNoWindow = true;
|
lsarProcess.StartInfo.CreateNoWindow = true;
|
||||||
@@ -328,7 +338,11 @@ namespace osrepodbmgr.Core
|
|||||||
lsarProcess.Start();
|
lsarProcess.Start();
|
||||||
string lsarOutput = lsarProcess.StandardOutput.ReadToEnd();
|
string lsarOutput = lsarProcess.StandardOutput.ReadToEnd();
|
||||||
lsarProcess.WaitForExit();
|
lsarProcess.WaitForExit();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.OpenArchive(): Took {0} seconds to list archive contents", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
long counter = 0;
|
long counter = 0;
|
||||||
string format = null;
|
string format = null;
|
||||||
JsonTextReader jsReader = new JsonTextReader(new StringReader(lsarOutput));
|
JsonTextReader jsReader = new JsonTextReader(new StringReader(lsarOutput));
|
||||||
@@ -343,6 +357,10 @@ namespace osrepodbmgr.Core
|
|||||||
format = jsReader.Value.ToString();
|
format = jsReader.Value.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.OpenArchive(): Took {0} seconds to process archive contents", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
Context.unzipWithUnAr = false;
|
Context.unzipWithUnAr = false;
|
||||||
Context.archiveFormat = format;
|
Context.archiveFormat = format;
|
||||||
@@ -368,6 +386,9 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
if(Context.usableDotNetZip)
|
if(Context.usableDotNetZip)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
ZipFile zf = ZipFile.Read(Context.path, new ReadOptions { Encoding = Encoding.UTF8 });
|
ZipFile zf = ZipFile.Read(Context.path, new ReadOptions { Encoding = Encoding.UTF8 });
|
||||||
foreach(ZipEntry ze in zf)
|
foreach(ZipEntry ze in zf)
|
||||||
{
|
{
|
||||||
@@ -378,6 +399,10 @@ namespace osrepodbmgr.Core
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.OpenArchive(): Took {0} seconds to navigate in search of Mac OS X metadata", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,6 +462,9 @@ namespace osrepodbmgr.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
ZipFile zf = ZipFile.Read(Context.path, new ReadOptions { Encoding = Encoding.UTF8 });
|
ZipFile zf = ZipFile.Read(Context.path, new ReadOptions { Encoding = Encoding.UTF8 });
|
||||||
zf.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
|
zf.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
|
||||||
zf.ExtractProgress += Zf_ExtractProgress;
|
zf.ExtractProgress += Zf_ExtractProgress;
|
||||||
@@ -466,6 +494,9 @@ namespace osrepodbmgr.Core
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
Context.unarProcess = new Process();
|
Context.unarProcess = new Process();
|
||||||
Context.unarProcess.StartInfo.FileName = Settings.Current.UnArchiverPath;
|
Context.unarProcess.StartInfo.FileName = Settings.Current.UnArchiverPath;
|
||||||
Context.unarProcess.StartInfo.CreateNoWindow = true;
|
Context.unarProcess.StartInfo.CreateNoWindow = true;
|
||||||
@@ -484,6 +515,10 @@ namespace osrepodbmgr.Core
|
|||||||
Context.unarProcess.WaitForExit();
|
Context.unarProcess.WaitForExit();
|
||||||
Context.unarProcess.Close();
|
Context.unarProcess.Close();
|
||||||
Context.unarProcess = null;
|
Context.unarProcess = null;
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.ExtractArchive(): Took {0} seconds to extract archive contents using UnAr", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
Finished();
|
Finished();
|
||||||
@@ -513,9 +548,14 @@ namespace osrepodbmgr.Core
|
|||||||
string.Format("{0} / {1}", e.BytesTransferred, e.TotalBytesToTransfer),
|
string.Format("{0} / {1}", e.BytesTransferred, e.TotalBytesToTransfer),
|
||||||
e.BytesTransferred, e.TotalBytesToTransfer);
|
e.BytesTransferred, e.TotalBytesToTransfer);
|
||||||
|
|
||||||
Console.WriteLine("{0}", e.EventType);
|
|
||||||
if(e.EventType == ZipProgressEventType.Extracting_AfterExtractAll && Finished != null)
|
if(e.EventType == ZipProgressEventType.Extracting_AfterExtractAll && Finished != null)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.Zf_ExtractProgress(): Took {0} seconds to extract archive contents using DotNetZip", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
Finished();
|
Finished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CompressTo()
|
public static void CompressTo()
|
||||||
@@ -575,6 +615,9 @@ namespace osrepodbmgr.Core
|
|||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress("", "Creating folders...", 3, 100);
|
UpdateProgress("", "Creating folders...", 3, 100);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
counter = 0;
|
counter = 0;
|
||||||
foreach(DBFolder folder in folders)
|
foreach(DBFolder folder in folders)
|
||||||
{
|
{
|
||||||
@@ -590,9 +633,16 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CompressTo(): Took {0} seconds to add folders to ZIP", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
counter = 3;
|
counter = 3;
|
||||||
Context.hashes = new Dictionary<string, DBOSFile>();
|
Context.hashes = new Dictionary<string, DBOSFile>();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(DBOSFile file in files)
|
foreach(DBOSFile file in files)
|
||||||
{
|
{
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
@@ -609,7 +659,11 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CompressTo(): Took {0} seconds to add files to ZIP", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
zipCounter = 0;
|
zipCounter = 0;
|
||||||
zipCurrentEntryName = "";
|
zipCurrentEntryName = "";
|
||||||
zf.Save();
|
zf.Save();
|
||||||
@@ -721,7 +775,13 @@ namespace osrepodbmgr.Core
|
|||||||
Failed("An error occurred creating ZIP file.");
|
Failed("An error occurred creating ZIP file.");
|
||||||
|
|
||||||
if(e.EventType == ZipProgressEventType.Saving_Completed && Finished != null)
|
if(e.EventType == ZipProgressEventType.Saving_Completed && Finished != null)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.Zf_SaveProgress(): Took {0} seconds to compress files to ZIP", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
Finished();
|
Finished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,21 @@ namespace osrepodbmgr.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
List<DBEntry> oses;
|
List<DBEntry> oses;
|
||||||
dbCore.DBOps.GetAllOSes(out oses);
|
dbCore.DBOps.GetAllOSes(out oses);
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.GetAllOSes(): Took {0} seconds to get OSes from database", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(AddOS != null)
|
if(AddOS != null)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
// TODO: Check file name and existence
|
// TODO: Check file name and existence
|
||||||
foreach(DBEntry os in oses)
|
foreach(DBEntry os in oses)
|
||||||
@@ -58,6 +68,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.GetAllOSes(): Took {0} seconds to add OSes to the GUI", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
@@ -77,6 +91,9 @@ namespace osrepodbmgr.Core
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
long counter = 0;
|
long counter = 0;
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(KeyValuePair<string, DBOSFile> kvp in Context.hashes)
|
foreach(KeyValuePair<string, DBOSFile> kvp in Context.hashes)
|
||||||
{
|
{
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
@@ -87,11 +104,19 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds to checks for file knowledge in the DB", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress(null, "Retrieving OSes from database", counter, Context.hashes.Count);
|
UpdateProgress(null, "Retrieving OSes from database", counter, Context.hashes.Count);
|
||||||
List<DBEntry> oses;
|
List<DBEntry> oses;
|
||||||
dbCore.DBOps.GetAllOSes(out oses);
|
dbCore.DBOps.GetAllOSes(out oses);
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds get all OSes from DB", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(oses != null && oses.Count > 0)
|
if(oses != null && oses.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -99,6 +124,9 @@ namespace osrepodbmgr.Core
|
|||||||
oses.CopyTo(osesArray);
|
oses.CopyTo(osesArray);
|
||||||
|
|
||||||
long osCounter = 0;
|
long osCounter = 0;
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(DBEntry os in osesArray)
|
foreach(DBEntry os in osesArray)
|
||||||
{
|
{
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
@@ -125,6 +153,10 @@ namespace osrepodbmgr.Core
|
|||||||
if(oses.Count == 0)
|
if(oses.Count == 0)
|
||||||
break; // No OSes left
|
break; // No OSes left
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CheckDbForFiles(): Took {0} seconds correlate all files with all known OSes", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AddOS != null)
|
if(AddOS != null)
|
||||||
@@ -158,6 +190,9 @@ namespace osrepodbmgr.Core
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
long counter = 0;
|
long counter = 0;
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(KeyValuePair<string, DBOSFile> kvp in Context.hashes)
|
foreach(KeyValuePair<string, DBOSFile> kvp in Context.hashes)
|
||||||
{
|
{
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
@@ -178,6 +213,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all files to the database", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress(null, "Adding OS information", counter, Context.hashes.Count);
|
UpdateProgress(null, "Adding OS information", counter, Context.hashes.Count);
|
||||||
@@ -186,6 +225,9 @@ namespace osrepodbmgr.Core
|
|||||||
UpdateProgress(null, "Creating OS table", counter, Context.hashes.Count);
|
UpdateProgress(null, "Creating OS table", counter, Context.hashes.Count);
|
||||||
dbCore.DBOps.CreateTableForOS(Context.dbInfo.id);
|
dbCore.DBOps.CreateTableForOS(Context.dbInfo.id);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
counter = 0;
|
counter = 0;
|
||||||
foreach(KeyValuePair<string, DBOSFile> kvp in Context.hashes)
|
foreach(KeyValuePair<string, DBOSFile> kvp in Context.hashes)
|
||||||
{
|
{
|
||||||
@@ -196,7 +238,11 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all files to the OS in the database", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
counter = 0;
|
counter = 0;
|
||||||
foreach(KeyValuePair<string, DBFolder> kvp in Context.foldersDict)
|
foreach(KeyValuePair<string, DBFolder> kvp in Context.foldersDict)
|
||||||
{
|
{
|
||||||
@@ -207,6 +253,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all folders to the database", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
Finished();
|
Finished();
|
||||||
@@ -305,6 +355,9 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
List<DBFile> files;
|
List<DBFile> files;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
while(dbCore.DBOps.GetFiles(out files, offset, page))
|
while(dbCore.DBOps.GetFiles(out files, offset, page))
|
||||||
{
|
{
|
||||||
if(files.Count == 0)
|
if(files.Count == 0)
|
||||||
@@ -319,6 +372,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
offset += page;
|
offset += page;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.GetFilesFromDb(): Took {0} seconds to get all files from the database", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
Finished();
|
Finished();
|
||||||
|
|||||||
@@ -90,9 +90,16 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress(null, "Detecting image format", 2, maxProgress);
|
UpdateProgress(null, "Detecting image format", 2, maxProgress);
|
||||||
_imageFormat = ImageFormat.Detect(inputFilter);
|
_imageFormat = ImageFormat.Detect(inputFilter);
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to detect image format", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(_imageFormat == null)
|
if(_imageFormat == null)
|
||||||
{
|
{
|
||||||
@@ -127,6 +134,9 @@ namespace osrepodbmgr.Core
|
|||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress(null, "Hashing image file", 3, maxProgress);
|
UpdateProgress(null, "Hashing image file", 3, maxProgress);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
byte[] data;
|
byte[] data;
|
||||||
long position = 0;
|
long position = 0;
|
||||||
while(position < (fi.Length - 524288))
|
while(position < (fi.Length - 524288))
|
||||||
@@ -151,6 +161,10 @@ namespace osrepodbmgr.Core
|
|||||||
imgChkWorker.Update(data);
|
imgChkWorker.Update(data);
|
||||||
|
|
||||||
fs.Close();
|
fs.Close();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to hash image file", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
List<ChecksumType> imgChecksums = imgChkWorker.End();
|
List<ChecksumType> imgChecksums = imgChkWorker.End();
|
||||||
|
|
||||||
@@ -192,6 +206,9 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
currentProgress = 3;
|
currentProgress = 3;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(MediaTagType tagType in _imageFormat.ImageInfo.readableMediaTags)
|
foreach(MediaTagType tagType in _imageFormat.ImageInfo.readableMediaTags)
|
||||||
{
|
{
|
||||||
currentProgress++;
|
currentProgress++;
|
||||||
@@ -342,6 +359,10 @@ namespace osrepodbmgr.Core
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to hash media tags", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -451,6 +472,9 @@ namespace osrepodbmgr.Core
|
|||||||
ulong sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1);
|
ulong sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1);
|
||||||
ulong doneSectors = 0;
|
ulong doneSectors = 0;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
while(doneSectors < sectors)
|
while(doneSectors < sectors)
|
||||||
{
|
{
|
||||||
byte[] sector;
|
byte[] sector;
|
||||||
@@ -474,6 +498,10 @@ namespace osrepodbmgr.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ChecksumType> trkChecksums = trkChkWorker.End();
|
List<ChecksumType> trkChecksums = trkChkWorker.End();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to hash track {1}", stopwatch.Elapsed.TotalSeconds, trk.TrackSequence);
|
||||||
|
#endif
|
||||||
|
|
||||||
xmlTrk.Checksums = trkChecksums.ToArray();
|
xmlTrk.Checksums = trkChecksums.ToArray();
|
||||||
|
|
||||||
@@ -518,6 +546,9 @@ namespace osrepodbmgr.Core
|
|||||||
sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1);
|
sectors = (ulong)(xmlTrk.EndSector - xmlTrk.StartSector + 1);
|
||||||
doneSectors = 0;
|
doneSectors = 0;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
while(doneSectors < sectors)
|
while(doneSectors < sectors)
|
||||||
{
|
{
|
||||||
byte[] sector;
|
byte[] sector;
|
||||||
@@ -543,6 +574,10 @@ namespace osrepodbmgr.Core
|
|||||||
List<ChecksumType> subChecksums = subChkWorker.End();
|
List<ChecksumType> subChecksums = subChkWorker.End();
|
||||||
|
|
||||||
xmlTrk.SubChannel.Checksums = subChecksums.ToArray();
|
xmlTrk.SubChannel.Checksums = subChecksums.ToArray();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to hash subchannel of track {1}", stopwatch.Elapsed.TotalSeconds, trk.TrackSequence);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(UpdateProgress2 != null)
|
if(UpdateProgress2 != null)
|
||||||
UpdateProgress2(null, null, 0, 0);
|
UpdateProgress2(null, null, 0, 0);
|
||||||
@@ -551,6 +586,9 @@ namespace osrepodbmgr.Core
|
|||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress(null, "Checking filesystems", maxProgress - 1, maxProgress);
|
UpdateProgress(null, "Checking filesystems", maxProgress - 1, maxProgress);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
List<Partition> partitions = new List<Partition>();
|
List<Partition> partitions = new List<Partition>();
|
||||||
|
|
||||||
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
|
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
|
||||||
@@ -648,6 +686,10 @@ namespace osrepodbmgr.Core
|
|||||||
if(lstFs.Count > 0)
|
if(lstFs.Count > 0)
|
||||||
xmlTrk.FileSystemInformation[0].FileSystems = lstFs.ToArray();
|
xmlTrk.FileSystemInformation[0].FileSystems = lstFs.ToArray();
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to check all filesystems on track {1}", stopwatch.Elapsed.TotalSeconds, trk.TrackSequence);
|
||||||
|
#endif
|
||||||
|
|
||||||
trksLst.Add(xmlTrk);
|
trksLst.Add(xmlTrk);
|
||||||
}
|
}
|
||||||
@@ -716,6 +758,9 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
currentProgress = 3;
|
currentProgress = 3;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
foreach(MediaTagType tagType in _imageFormat.ImageInfo.readableMediaTags)
|
foreach(MediaTagType tagType in _imageFormat.ImageInfo.readableMediaTags)
|
||||||
{
|
{
|
||||||
currentProgress++;
|
currentProgress++;
|
||||||
@@ -803,6 +848,10 @@ namespace osrepodbmgr.Core
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to hash media tags", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
string dskType, dskSubType;
|
string dskType, dskSubType;
|
||||||
DiscImageChef.Metadata.MediaType.MediaTypeToString(_imageFormat.ImageInfo.mediaType, out dskType, out dskSubType);
|
DiscImageChef.Metadata.MediaType.MediaTypeToString(_imageFormat.ImageInfo.mediaType, out dskType, out dskSubType);
|
||||||
@@ -819,6 +868,9 @@ namespace osrepodbmgr.Core
|
|||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress(null, "Checking filesystems", maxProgress - 1, maxProgress);
|
UpdateProgress(null, "Checking filesystems", maxProgress - 1, maxProgress);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
List<Partition> partitions = new List<Partition>();
|
List<Partition> partitions = new List<Partition>();
|
||||||
|
|
||||||
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
|
foreach(PartPlugin _partplugin in plugins.PartPluginsList.Values)
|
||||||
@@ -901,6 +953,10 @@ namespace osrepodbmgr.Core
|
|||||||
if(lstFs.Count > 0)
|
if(lstFs.Count > 0)
|
||||||
sidecar.BlockMedia[0].FileSystemInformation[0].FileSystems = lstFs.ToArray();
|
sidecar.BlockMedia[0].FileSystemInformation[0].FileSystems = lstFs.ToArray();
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.AddMedia(): Took {0} seconds to check all filesystems", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO: Implement support for getting CHS
|
// TODO: Implement support for getting CHS
|
||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
|
|||||||
@@ -66,10 +66,22 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
Context.files = new List<string>(Directory.EnumerateFiles(filesPath, "*", SearchOption.AllDirectories));
|
Context.files = new List<string>(Directory.EnumerateFiles(filesPath, "*", SearchOption.AllDirectories));
|
||||||
Context.files.Sort();
|
Context.files.Sort();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.FindFiles(): Took {0} seconds to find all files", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
Context.folders = new List<string>(Directory.EnumerateDirectories(filesPath, "*", SearchOption.AllDirectories));
|
Context.folders = new List<string>(Directory.EnumerateDirectories(filesPath, "*", SearchOption.AllDirectories));
|
||||||
Context.folders.Sort();
|
Context.folders.Sort();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.FindFiles(): Took {0} seconds to find all folders", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
Finished();
|
Finished();
|
||||||
}
|
}
|
||||||
@@ -116,6 +128,9 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
// End for metadata
|
// End for metadata
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
long counter = 1;
|
long counter = 1;
|
||||||
foreach(string file in Context.files)
|
foreach(string file in Context.files)
|
||||||
{
|
{
|
||||||
@@ -378,7 +393,11 @@ namespace osrepodbmgr.Core
|
|||||||
Context.hashes.Add(relpath, dbFile);
|
Context.hashes.Add(relpath, dbFile);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.HashFiles(): Took {0} seconds to hash all files", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
counter = 1;
|
counter = 1;
|
||||||
foreach(string folder in Context.folders)
|
foreach(string folder in Context.folders)
|
||||||
{
|
{
|
||||||
@@ -405,6 +424,10 @@ namespace osrepodbmgr.Core
|
|||||||
Context.foldersDict.Add(relpath, dbFolder);
|
Context.foldersDict.Add(relpath, dbFolder);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.HashFiles(): Took {0} seconds to iterate all folders", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(foundMetadata)
|
if(foundMetadata)
|
||||||
{
|
{
|
||||||
@@ -522,6 +545,9 @@ namespace osrepodbmgr.Core
|
|||||||
FileStream inFs = new FileStream(Context.path, FileMode.Open, FileAccess.Read);
|
FileStream inFs = new FileStream(Context.path, FileMode.Open, FileAccess.Read);
|
||||||
FileStream outFs = new FileStream(Context.tmpFolder, FileMode.Create, FileAccess.Write);
|
FileStream outFs = new FileStream(Context.tmpFolder, FileMode.Create, FileAccess.Write);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
byte[] buffer = new byte[bufferSize];
|
byte[] buffer = new byte[bufferSize];
|
||||||
|
|
||||||
while((inFs.Position + bufferSize) <= inFs.Length)
|
while((inFs.Position + bufferSize) <= inFs.Length)
|
||||||
@@ -542,6 +568,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
inFs.Close();
|
inFs.Close();
|
||||||
outFs.Close();
|
outFs.Close();
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.CopyFile(): Took {0} seconds to copy file", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
Finished();
|
Finished();
|
||||||
@@ -597,6 +627,9 @@ namespace osrepodbmgr.Core
|
|||||||
if(UpdateProgress != null)
|
if(UpdateProgress != null)
|
||||||
UpdateProgress("", "Creating folders...", 3, 100);
|
UpdateProgress("", "Creating folders...", 3, 100);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
counter = 0;
|
counter = 0;
|
||||||
foreach(DBFolder folder in folders)
|
foreach(DBFolder folder in folders)
|
||||||
{
|
{
|
||||||
@@ -611,7 +644,14 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.SaveAs(): Took {0} seconds to create all folders", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Restart();
|
||||||
|
#endif
|
||||||
counter = 3;
|
counter = 3;
|
||||||
foreach(DBOSFile file in files)
|
foreach(DBOSFile file in files)
|
||||||
{
|
{
|
||||||
@@ -718,6 +758,10 @@ namespace osrepodbmgr.Core
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
#if DEBUG
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine("Core.SaveAs(): Took {0} seconds to create all files", stopwatch.Elapsed.TotalSeconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(Finished != null)
|
if(Finished != null)
|
||||||
Finished();
|
Finished();
|
||||||
|
|||||||
@@ -306,8 +306,13 @@ namespace osrepodbmgr.Core
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
stopwatch.Restart();
|
stopwatch.Restart();
|
||||||
#endif
|
#endif
|
||||||
|
int counter = 0;
|
||||||
while(fResult.ResponseCode == VirusTotalNET.ResponseCodes.ReportResponseCode.StillQueued)
|
while(fResult.ResponseCode == VirusTotalNET.ResponseCodes.ReportResponseCode.StillQueued)
|
||||||
{
|
{
|
||||||
|
// Timeout...
|
||||||
|
if(counter == 10)
|
||||||
|
break;
|
||||||
|
|
||||||
// Wait 15 seconds so we fall in the 4 requests/minute
|
// Wait 15 seconds so we fall in the 4 requests/minute
|
||||||
Thread.Sleep(15000);
|
Thread.Sleep(15000);
|
||||||
|
|
||||||
@@ -315,6 +320,8 @@ namespace osrepodbmgr.Core
|
|||||||
{
|
{
|
||||||
fResult = await vTotal.GetFileReport(file.Sha256);
|
fResult = await vTotal.GetFileReport(file.Sha256);
|
||||||
}).Wait();
|
}).Wait();
|
||||||
|
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user