Skip to content

Commit d72233b

Browse files
CopilotJusterZhu
andcommitted
Remove dependency on DownloadUrl property and use ServerUrl for all downloads
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
1 parent 506601a commit d72233b

1 file changed

Lines changed: 7 additions & 25 deletions

File tree

src/c#/GeneralUpdate.Extension/Services/ExtensionService.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,8 @@ public async Task<HttpResponseDTO<DownloadExtensionDTO>> Download(string id)
316316
{
317317
_updateQueue.ChangeState(operation.OperationId, GeneralUpdate.Extension.Download.UpdateState.Updating);
318318

319-
// Determine file format from descriptor or default to .zip
320-
var format = !string.IsNullOrWhiteSpace(descriptor.DownloadUrl) && descriptor.DownloadUrl!.Contains(".")
321-
? Path.GetExtension(descriptor.DownloadUrl)
322-
: ".zip";
319+
// Default to .zip format
320+
var format = ".zip";
323321

324322
// Create version info for the download manager
325323
var versionInfo = new VersionInfo
@@ -449,6 +447,9 @@ private ExtensionDTO MapToExtensionDTO(AvailableExtension extension, Version? ho
449447
isCompatible = _validator.IsCompatible(descriptor);
450448
}
451449

450+
// Construct download URL from server URL
451+
var downloadUrl = $"{_serverUrl}/Download/{descriptor.Name}";
452+
452453
return new ExtensionDTO
453454
{
454455
Id = descriptor.Name ?? string.Empty,
@@ -459,7 +460,7 @@ private ExtensionDTO MapToExtensionDTO(AvailableExtension extension, Version? ho
459460
UploadTime = descriptor.ReleaseDate,
460461
Status = true, // Assume enabled if it's in the available list
461462
Description = descriptor.Description,
462-
Format = GetFileFormat(descriptor.DownloadUrl),
463+
Format = ".zip", // Default format
463464
Hash = descriptor.PackageHash,
464465
Publisher = descriptor.Publisher,
465466
License = descriptor.License,
@@ -470,29 +471,10 @@ private ExtensionDTO MapToExtensionDTO(AvailableExtension extension, Version? ho
470471
ReleaseDate = descriptor.ReleaseDate,
471472
Dependencies = descriptor.Dependencies,
472473
IsPreRelease = extension.IsPreRelease,
473-
DownloadUrl = descriptor.DownloadUrl,
474+
DownloadUrl = downloadUrl, // Use constructed URL from server
474475
CustomProperties = descriptor.CustomProperties,
475476
IsCompatible = isCompatible
476477
};
477478
}
478-
479-
/// <summary>
480-
/// Extracts file format from download URL
481-
/// </summary>
482-
private string? GetFileFormat(string? downloadUrl)
483-
{
484-
if (string.IsNullOrWhiteSpace(downloadUrl))
485-
return null;
486-
487-
try
488-
{
489-
var extension = Path.GetExtension(downloadUrl);
490-
return string.IsNullOrWhiteSpace(extension) ? null : extension;
491-
}
492-
catch
493-
{
494-
return null;
495-
}
496-
}
497479
}
498480
}

0 commit comments

Comments
 (0)