Fix for the temp folder being on a different drive.

This commit is contained in:
Timothy Baldridge 2020-04-04 11:25:54 -06:00
parent 615f059bd5
commit 07bc3546bb
2 changed files with 32 additions and 3 deletions

View File

@ -136,7 +136,7 @@ namespace Wabbajack.BuildServer.Controllers
var originalName = $"{parts[0]}{parts[2]}";
var finalPath = "public".RelativeTo(AbsolutePath.EntryPoint).Combine("files", finalName);
_settings.TempPath.Combine(Key).MoveTo(finalPath);
await _settings.TempPath.Combine(Key).MoveToAsync(finalPath);
var hash = await finalPath.FileHashAsync();

View File

@ -156,15 +156,44 @@ namespace Wabbajack.Common
throw new ArgumentException("Could not find entry point.");
return ((AbsolutePath)location).Parent;
}
}
}
public AbsolutePath Root => (AbsolutePath)Path.GetPathRoot(_path);
/// <summary>
/// Moves this file to the specified location
/// Moves this file to the specified location, will use Copy if required
/// </summary>
/// <param name="otherPath"></param>
/// <param name="overwrite">Replace the destination file if it exists</param>
public void MoveTo(AbsolutePath otherPath, bool overwrite = false)
{
if (Root != otherPath.Root)
{
if (otherPath.Exists && overwrite)
otherPath.Delete();
CopyTo(otherPath);
return;
}
File.Move(_path, otherPath._path, overwrite ? MoveOptions.ReplaceExisting : MoveOptions.None);
}
/// <summary>
/// Moves this file to the specified location, will use Copy if required
/// </summary>
/// <param name="otherPath"></param>
/// <param name="overwrite">Replace the destination file if it exists</param>
public async Task MoveToAsync(AbsolutePath otherPath, bool overwrite = false)
{
if (Root != otherPath.Root)
{
if (otherPath.Exists && overwrite)
otherPath.Delete();
await CopyToAsync(otherPath);
Delete();
return;
}
File.Move(_path, otherPath._path, overwrite ? MoveOptions.ReplaceExisting : MoveOptions.None);
}