That spooky error
This code error with “file already exists”, figure out why :-)
public override IndexOutput CreateOutput(string name) { transactionalStorage.Batch(actions => { if (actions.FileExistsInDirectory(directory, name) == false) ; actions.CreateFileInDirectory(directory, name); }); return OpenSession<IndexOutput>(name, true, (stream, action) => new EsentIndexOutput(stream, action)); }
Nasty, ain’t it?
Comments
rogue semi-colon for true-case of "if" test..
Semicolon (;) after if statement ends the if-scope immediately (no brackets used), so the CreateFile statement is always executed...
That is why I have adopted the style of embedding all statements --- even one liners --- in curly braces.
This is why I don't ignore warnings in the IDE. Far more useful than making all your code unreadable.
Resharper much? Reformat and it will at the least change the indentation appropriately.
Even without resharper, I use the Visual Studio shortcut ctrl-K ctrl-D several times a day.
Ayende, you should refactor your code a bit. Excessive use of lambdas make the code nearly unreadable.
@Frank
You mean like creating a single method for the "(stream, action) => new EsentIndexOutput(stream, action)" which might be only used there?
I really don't see the point in that.
And yes, ReSharper/warnings should have pointed it out :)
Use Resharper. It highlights stuff like that.
Comment preview