hashdir
hashdir copied to clipboard
System.NullReferenceException when checking root of a drive in Windows, e.g. D:
System: Windows 10
Folder structure:
D:
--Folder 1
--hashdir
----check.bat
----hashdir_1.4.1_Windows_64bit
------hashdir.exe
--a.txt
--b.txt
check.bat:
.\hashdir_1.4.1_Windows_64bit\hashdir.exe -a md5 --tree --save "../"
pause
Goal: Create hashes for all files in the parent folder. In this example hashdir is part of that directory and checksums itself.
Output:
Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
at HashUtil.Util.cleanPath(String path)
at Program.rootHandler(RootOpt opt)
at System.CommandLine.Invocation.AnonymousCommandHandler.Invoke(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()
Moving all files in hashdir/ to hashdir/test/ solved the issue. However, without touching the bat file it then of course only checks the contents of D:/hashdir/ instead of D:. When I then change the relative path from ../ to ../../ I get the error again. I therefore seem to get it when checking the root level of a drive.
Edit: Simplified example by removing --ignore rule. Issue did not change.