forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RavenDB-21858 Cannot download the dump file generated by /admin/debug…
…/dump endpoint
- Loading branch information
1 parent
c709374
commit ccd1d2e
Showing
5 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using Sparrow.Platform; | ||
|
||
namespace Raven.Debug.Utils; | ||
|
||
public static class PosixFileExtensions | ||
{ | ||
public static void ChangeFileOwner(string fileName, string owner) | ||
{ | ||
if (PlatformDetails.RunningOnPosix == false) | ||
throw new InvalidOperationException("This method is supposed to be called only on Posix systems"); | ||
|
||
var startup = new ProcessStartInfo | ||
{ | ||
FileName = "chown", | ||
Arguments = $"{owner}:{owner} {fileName}", | ||
UseShellExecute = false, | ||
RedirectStandardOutput = false, | ||
RedirectStandardError = true | ||
}; | ||
|
||
var process = new Process | ||
{ | ||
StartInfo = startup, | ||
EnableRaisingEvents = true | ||
}; | ||
|
||
process.Start(); | ||
process.WaitForExit(); | ||
|
||
|
||
if (process.ExitCode == 0) | ||
return; | ||
|
||
var error = process.StandardError.ReadToEnd(); | ||
|
||
throw new InvalidOperationException($"Error changing file owner: {error}"); | ||
} | ||
} |