Skip to content

Commit

Permalink
VCI-821: Add check for symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro committed Mar 5, 2024
1 parent f2983af commit 6051c87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private static bool PlatformVersionChanged()
modulesDirs = Directory.EnumerateDirectories(discoveryPath).ToList();
}
var symlinks = modulesDirs.Where(m => new DirectoryInfo(m).LinkTarget != null).ToList();
CompressionExtensions.TarGZipTo(RootDirectory, BackupFile, filter: f => !f.ToFileInfo().FullName.StartsWith(RootDirectory / ".nuke") && !symlinks.Any(s => f.ToFileInfo().FullName.StartsWith(s)));
CompressionExtensions.TarGZipTo(RootDirectory, BackupFile, filter: f => !f.ToFileInfo().FullName.StartsWith(RootDirectory / ".nuke") && !symlinks.Exists(s => f.ToFileInfo().FullName.StartsWith(s)));
});

public Target Rollback => _ => _
Expand Down Expand Up @@ -347,7 +347,7 @@ private static bool IsPlatformInstallationNeeded(string version)
return;
}
if (alreadyInstalledModules.Exists(installedModule => installedModule.ModuleName == module.Id && installedModule.Version.ToString() == module.Version) || localModuleCatalog.IsModuleFromSourceCode(module.Id))
if (alreadyInstalledModules.Exists(installedModule => installedModule.ModuleName == module.Id && installedModule.Version.ToString() == module.Version) || localModuleCatalog.IsModuleSymlinked(module.Id))
{
continue;
}
Expand Down Expand Up @@ -656,13 +656,25 @@ private static ManifestBase CreateManifestFromEnvironment(AbsolutePath platformP
var platformVersion = platformWebDllFileInfo.ProductVersion;
var packageManifest = PackageManager.CreatePackageManifest(platformVersion);
var githubModules = PackageManager.GetGithubModules(packageManifest);

var githubModulesSource = PackageManager.GetGithubModulesSource(packageManifest);
var localModuleCatalog = (LocalCatalog)LocalModuleCatalog.GetCatalog(GetDiscoveryPath(), ProbingPath);
var externalModuleCatalog = ExtModuleCatalog.GetCatalog(GitHubToken, localModuleCatalog, githubModulesSource.ModuleSources).GetAwaiter().GetResult();
var modulesInCatalog = externalModuleCatalog.Modules.Where(m => !m.Ref.StartsWith("file://")).Select(m => m.ModuleName).ToList();
var manifests = discoveryPath.GlobFiles("*/module.manifest");
manifests.ForEach(m =>
{
var manifest = ManifestReader.Read(m);
githubModules.Add(new ModuleItem(manifest.Id, manifest.Version));
if (!modulesInCatalog.Contains(manifest.Id))
{
Log.Warning("There is no module {0}:{1} in external catalog. You should add it in manifest manually.", manifest.Id, manifest.Version);
}
else
{
githubModules.Add(new ModuleItem(manifest.Id, manifest.Version));
}
});

return packageManifest;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace PlatformTools.Extensions
{
public static class LocalModuleCatalogExtensions
{
public static bool IsModuleFromSourceCode(this ILocalModuleCatalog moduleCatalog, string moduleId)
public static bool IsModuleSymlinked(this ILocalModuleCatalog moduleCatalog, string moduleId)
{
var moduleInfo = moduleCatalog.Modules.OfType<ManifestModuleInfo>().FirstOrDefault(m => m.ModuleName == moduleId);
if(moduleInfo == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static IOptions<ExternalModuleCatalogOptions> GetOptions(string authToken
{
var options = new ExternalModuleCatalogOptions
{
ModulesManifestUrl = new Uri(manifestUrls.First()),
ModulesManifestUrl = new Uri(manifestUrls[0]),
AuthorizationToken = authToken,
IncludePrerelease = false,
AutoInstallModuleBundles = Array.Empty<string>(),
Expand Down

0 comments on commit 6051c87

Please sign in to comment.