Skip to content

Commit 94518be

Browse files
committed
Clean up console output
1 parent f93e368 commit 94518be

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

Diff for: Analyzer/AnalyzerTool.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public int Analyze(string path, string databaseName, string searchPattern, bool
3030
int lastLength = 0;
3131
foreach (var file in files)
3232
{
33+
// Automatically ignore these annoying OS X style files meta files.
34+
if (Path.GetFileName(file) == ".DS_Store")
35+
continue;
36+
3337
try
3438
{
3539
UnityArchive archive = null;
@@ -44,9 +48,11 @@ public int Analyze(string path, string databaseName, string searchPattern, bool
4448

4549
var relativePath = Path.GetRelativePath(path, file);
4650

47-
Console.Write($"\rProcessing {i * 100 / files.Length}% ({i}/{files.Length}) {file}");
48-
4951
writer.WriteSerializedFile(relativePath, file, Path.GetDirectoryName(file));
52+
53+
var message = $"Processing {i * 100 / files.Length}% ({i}/{files.Length}) {file}";
54+
Console.Write($"\rProcessing {i * 100 / files.Length}% ({i}/{files.Length}) {file}");
55+
lastLength = message.Length;
5056
}
5157

5258
if (archive != null)
@@ -71,22 +77,29 @@ public int Analyze(string path, string databaseName, string searchPattern, bool
7177
}
7278
catch (Exception e)
7379
{
74-
Console.Error.WriteLine($"Error processing {node.Path} in archive {file}");
80+
Console.Error.WriteLine($"\rError processing {node.Path} in archive {file}{new string(' ', Math.Max(0, lastLength - message.Length))}");
81+
Console.Error.WriteLine(e);
82+
Console.WriteLine();
7583
}
7684
}
7785
}
7886
}
7987
finally
8088
{
89+
Console.Write($"\r{new string(' ', lastLength)}");
8190
writer.EndAssetBundle();
8291
archive.Dispose();
8392
}
8493
}
8594
}
86-
catch (Exception e)
95+
catch(NotSupportedException) {
96+
Console.Error.WriteLine();
97+
//Console.Error.WriteLine($"File not supported: {file}"); // This is commented out because another codepath will output "failed to load"
98+
}
99+
catch (Exception e)
87100
{
88101
Console.Error.WriteLine();
89-
Console.Error.WriteLine($"Error processing file {file}!");
102+
Console.Error.WriteLine($"Error processing file: {file}");
90103
Console.Write($"{e.GetType()}: ");
91104
Console.WriteLine(e.Message);
92105
Console.WriteLine(e.StackTrace);

Diff for: Analyzer/PPtrAndCrcProcessor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private void ProcessManagedReferenceRegistry(TypeTreeNode node)
290290
}
291291
else
292292
{
293-
throw new Exception("Unsupported ManagedReferenceRegistry version");
293+
throw new Exception($"Unsupported ManagedReferenceRegistry version {version}");
294294
}
295295
}
296296

Diff for: Analyzer/SQLite/SQLiteWriter.cs

+4-13
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ public void Begin()
7878

7979
foreach (var handler in m_Handlers.Values)
8080
{
81-
Console.WriteLine($"Init handler: {handler.GetType().Name}");
82-
Console.WriteLine($"Connection state before init: {m_Database.State}");
81+
// Console.WriteLine($"Init handler: {handler.GetType().Name}");
82+
// Console.WriteLine($"Connection state before init: {m_Database.State}");
8383
handler.Init(m_Database);
84-
Console.WriteLine($"Connection state after init: {m_Database.State}");
84+
// Console.WriteLine($"Connection state after init: {m_Database.State}");
8585

8686
}
8787

@@ -289,15 +289,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con
289289

290290
if (!m_SkipReferences)
291291
{
292-
try
293-
{
294-
crc32 = pptrReader.Process(currentObjectId, offset, root);
295-
}
296-
catch (Exception e)
297-
{
298-
Console.Error.WriteLine(e);
299-
throw;
300-
}
292+
crc32 = pptrReader.Process(currentObjectId, offset, root);
301293
}
302294

303295
m_AddObjectCommand.Parameters["@id"].Value = currentObjectId;
@@ -325,7 +317,6 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con
325317
}
326318
catch (Exception e)
327319
{
328-
Console.Error.WriteLine($"Error processing {serializedFileId} error: {e.Message}");
329320
transaction.Rollback();
330321
throw;
331322
}

Diff for: TextDumper/TextDumperTool.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void DumpManagedReferenceRegistry(TypeTreeNode node, ref long offset, int level)
262262
}
263263
else
264264
{
265-
throw new Exception("Unsupported ManagedReferenceRegistry version");
265+
throw new Exception($"Unsupported ManagedReferenceRegistry version {version}");
266266
}
267267
}
268268

Diff for: UnityFileSystem/TypeTreeReaders/RandomAccessReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public RandomAccessReader(SerializedFile serializedFile, TypeTreeNode node, Unit
117117
}
118118
else
119119
{
120-
throw new Exception("Unsupported ManagedReferenceRegistry version");
120+
throw new Exception($"Unsupported ManagedReferenceRegistry version {version}");
121121
}
122122
}
123123
else if (isReferencedObject)

0 commit comments

Comments
 (0)