Skip to content

[bug] Fatal crash when reset stashed new file in new folder #1434

@NathanBaulch

Description

@NathanBaulch

Fatal crash when selecting Reset to This Revision on a stash change that introduces a new file in a new folder.
Probably just need a Directory.CreateDirectory(Path.GetDirectoryName(outputFile)) or similar in SaveRevisionFile.ExecCmd.
Also, would be good if the app could catch unexpected errors like this rather than simply disappearing.

System.IO.DirectoryNotFoundException: Could not find a part of the path '/home/nathan/foo/modules/deploy/variables.tf'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.OpenWrite(String path)
   at SourceGit.Commands.SaveRevisionFile.ExecCmd(String repo, String args, String outputFile, Stream input) in /home/nathan/ghq/github.com/sourcegit-scm/sourcegit/src/Commands/SaveRevisionFile.cs:line 38
   at SourceGit.Commands.SaveRevisionFile.Run(String repo, String revision, String file, String saveTo) in /home/nathan/ghq/github.com/sourcegit-scm/sourcegit/src/Commands/SaveRevisionFile.cs:line 21
   at SourceGit.ViewModels.StashesPage.<>c__DisplayClass24_2.<MakeContextMenuForChange>b__6() in /home/nathan/ghq/github.com/sourcegit-scm/sourcegit/src/ViewModels/StashesPage.cs:line 262
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions