Skip to content

Commit

Permalink
[build] 0.3.0
Browse files Browse the repository at this point in the history
Removed file deletion if build-files.txt not found
  • Loading branch information
openbullet committed Jul 1, 2024
1 parent 9c97e9d commit bc5c022
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 71 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '.release/*'
file_glob: true
release_name: ${{ env.VERSION }}
tag: ${{ env.VERSION }}
overwrite: true
prerelease: false
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '.release/*'
file_glob: true
release_name: ${{ env.VERSION }}
tag: ${{ env.VERSION }}
overwrite: true
prerelease: true
Expand Down
37 changes: 2 additions & 35 deletions OpenBullet2.Native.Updater/Helpers/FileSystemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,45 +71,12 @@ public static async Task CleanupInstallationFolderAsync()
}
}
});

}
// If the file does not exist, we will delete everything except the whitelisted files and folders.
// If the file does not exist, skip the deletion
else
{
AnsiConsole.MarkupLine(
"[yellow]build-files.txt not found, cleaning up everything not in the whitelist...[/]");

AnsiConsole.Status()
.Start("[yellow]Deleting...[/]", ctx =>
{
foreach (var entry in Directory.EnumerateFileSystemEntries(Directory.GetCurrentDirectory()))
{
var isDirectory = (File.GetAttributes(entry) & FileAttributes.Directory) == FileAttributes.Directory;

// If it even contains appsettings.json or UserData, disregard it (prevent accidental deletion)
if (entry.Contains("appsettings.json") || entry.Contains("UserData"))
{
continue;
}

// If it's the current executable, disregard it
if (entry == Process.GetCurrentProcess().MainModule?.FileName)
{
continue;
}

ctx.Status($"Deleting {entry}...");

if (isDirectory)
{
Directory.Delete(entry, true);
}
else
{
File.Delete(entry);
}
}
});
"[yellow]build-files.txt not found, skipping file deletion...[/]");
}
}

Expand Down
39 changes: 3 additions & 36 deletions OpenBullet2.Web.Updater/Helpers/FileSystemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,45 +71,12 @@ public static async Task CleanupInstallationFolderAsync()
}
}
});

}
// If the file does not exist, we will delete everything except the whitelisted files and folders.
// If the file does not exist, skip the deletion
else
{
{
AnsiConsole.MarkupLine(
"[yellow]build-files.txt not found, cleaning up everything not in the whitelist...[/]");

AnsiConsole.Status()
.Start("[yellow]Deleting...[/]", ctx =>
{
foreach (var entry in Directory.EnumerateFileSystemEntries(Directory.GetCurrentDirectory()))
{
var isDirectory = (File.GetAttributes(entry) & FileAttributes.Directory) == FileAttributes.Directory;

// If it even contains appsettings.json or UserData, disregard it (prevent accidental deletion)
if (entry.Contains("appsettings.json") || entry.Contains("UserData"))
{
continue;
}

// If it's the current executable, disregard it
if (entry == Process.GetCurrentProcess().MainModule?.FileName)
{
continue;
}

ctx.Status($"Deleting {entry}...");

if (isDirectory)
{
Directory.Delete(entry, true);
}
else
{
File.Delete(entry);
}
}
});
"[yellow]build-files.txt not found, skipping file deletion...[/]");
}
}

Expand Down

0 comments on commit bc5c022

Please sign in to comment.