Skip to content

Commit

Permalink
Rationalize filesystem constants
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Aug 6, 2024
1 parent 1683ff6 commit 08a6f91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 3 additions & 5 deletions Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace Meadow.CLI.Commands.DeviceManagement;

internal static class AppTools
{
internal const string MeadowRootFolder = "meadow0";

internal static string ValidateAndSanitizeAppPath(string? path)
{
path ??= Directory.GetCurrentDirectory();
Expand Down Expand Up @@ -124,15 +122,15 @@ internal static string SanitizeMeadowFilename(string fileName)

if (string.IsNullOrWhiteSpace(folder))
{
folder = Path.DirectorySeparatorChar + MeadowRootFolder;
folder = Path.DirectorySeparatorChar + AppManager.MeadowRootFolder;
}
else
{
if (!folder.StartsWith(Path.DirectorySeparatorChar))
{
if (!folder.StartsWith($"{MeadowRootFolder}"))
if (!folder.StartsWith($"{AppManager.MeadowRootFolder}"))
{
folder = $"{Path.DirectorySeparatorChar}{MeadowRootFolder}{Path.DirectorySeparatorChar}{folder}";
folder = $"{Path.DirectorySeparatorChar}{AppManager.MeadowRootFolder}{Path.DirectorySeparatorChar}{folder}";
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions Source/v2/Meadow.Tooling.Core/App/AppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ namespace Meadow.CLI;

public static class AppManager
{
static readonly string MeadowRootFolder = "meadow0";
public static readonly string MeadowRootFolder = "meadow0";

static readonly string[] PersistantFolders = new string[]
public static readonly string[] PersistantFolders = new string[]
{
"Data",
"Documents",
"update-store",
"system",
};

private static bool MatchingDllExists(string file)
Expand Down Expand Up @@ -132,6 +133,11 @@ public static async Task DeployApplication(
// delete those files
foreach (var file in removeFiles)
{
if (PersistantFolders.Contains(file.Path))
{
continue;
}

logger?.LogInformation($"Deleting '{file}'");
var folder = string.IsNullOrEmpty(file.Path) ? $"/{MeadowRootFolder}/" : $"/{MeadowRootFolder}/{file.Path}/";

Expand Down

0 comments on commit 08a6f91

Please sign in to comment.