-
Notifications
You must be signed in to change notification settings - Fork 404
Expand file tree
/
Copy pathSaveDiscardOnTrash.cs
More file actions
28 lines (23 loc) · 940 Bytes
/
SaveDiscardOnTrash.cs
File metadata and controls
28 lines (23 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace SourceGit.Commands
{
public static class SaveDiscardOnTrash
{
public static async Task<bool> ProcessSaveDiscardOnTrash(string repo, List<Models.Change> changes)
{
changes ??= await new QueryLocalChanges(repo).GetResultAsync().ConfigureAwait(false);
string tempFolder = Path.GetTempPath();
string fileName = $"discard_{DateTime.Now.Ticks}.patch";
string fileNameTemp = Path.Combine(tempFolder, fileName);
// Save the patch in the Temp Folder
var succ = await SaveChangesAsPatch.ProcessLocalChangesAsync(repo, changes, true, fileNameTemp);
if (succ) return false;
// Move the file in the Trash
if(!Native.OS.MoveFileToTrash(fileNameTemp)) return false;
return false;
}
}
}