Skip to content

Commit

Permalink
Fix ambiguous System.IO.Path reference
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Jan 16, 2025
1 parent f8b0dba commit 3910173
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions backend/LexBoxApi/Services/ProjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Path = System.IO.Path; // Resolves ambiguous reference with HotChocolate.Path

namespace LexBoxApi.Services;

Expand Down Expand Up @@ -276,7 +277,7 @@ public async Task ResetLexEntryCount(string projectCode)
if (project.Type != ProjectType.FLEx) return null;
var zip = await hgService.GetLdmlZip(project.Code, token);
if (zip is null) return null;
var path = System.IO.Path.Join(destRoot, project.Id.ToString());
var path = Path.Join(destRoot, project.Id.ToString());
if (Directory.Exists(path)) Directory.Delete(path, true);
var dirInfo = Directory.CreateDirectory(path);
zip.ExtractToDirectory(dirInfo.FullName, true);
Expand All @@ -285,17 +286,17 @@ public async Task ResetLexEntryCount(string projectCode)

public async Task<string> PrepareLdmlZip(CancellationToken token = default)
{
var path = System.IO.Path.Join(System.IO.Path.GetTempPath(), "ldml-zip"); // TODO: pick random name, rather than predictable one
var path = Path.Join(Path.GetTempPath(), "ldml-zip"); // TODO: pick random name, rather than predictable one
if (Directory.Exists(path)) Directory.Delete(path, true);
Directory.CreateDirectory(path);
await DeleteTempDirectoryJob.Queue(schedulerFactory, path, TimeSpan.FromHours(4));
var zipRoot = System.IO.Path.Join(path, "zipRoot");
var zipRoot = Path.Join(path, "zipRoot");
Directory.CreateDirectory(zipRoot);
await foreach (var project in dbContext.Projects.Where(p => p.Type == ProjectType.FLEx).AsAsyncEnumerable())
{
await ExtractLdmlZip(project, zipRoot, token);
}
var zipFilePath = System.IO.Path.Join(path, "ldml.zip"); // TODO: Put timestamp in there
var zipFilePath = Path.Join(path, "ldml.zip"); // TODO: Put timestamp in there
if (File.Exists(zipFilePath)) File.Delete(zipFilePath);
ZipFile.CreateFromDirectory(zipRoot, zipFilePath, CompressionLevel.Fastest, includeBaseDirectory: false);
return zipFilePath;
Expand Down
3 changes: 2 additions & 1 deletion backend/LexCore/ServiceInterfaces/IHgService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LexCore.Entities;
using System.IO.Compression;

namespace LexCore.ServiceInterfaces;

Expand All @@ -22,7 +23,7 @@ public interface IHgService
Task<int?> GetRepoSizeInKb(ProjectCode code, CancellationToken token = default);
Task<int?> GetLexEntryCount(ProjectCode code, ProjectType projectType);
Task<string?> GetRepositoryIdentifier(Project project);
Task<System.IO.Compression.ZipArchive?> GetLdmlZip(ProjectCode code, CancellationToken token = default);
Task<ZipArchive?> GetLdmlZip(ProjectCode code, CancellationToken token = default);
Task<HttpContent> ExecuteHgRecover(ProjectCode code, CancellationToken token);
Task<HttpContent> InvalidateDirCache(ProjectCode code, CancellationToken token = default);
bool HasAbandonedTransactions(ProjectCode projectCode);
Expand Down

0 comments on commit 3910173

Please sign in to comment.