Skip to content

Commit c2b7103

Browse files
committed
Download export file was using wrong profile id
1 parent 21cb55e commit c2b7103

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,24 +1070,29 @@ public ActionResult DownloadLogFile(int id)
10701070

10711071
public ActionResult DownloadExportFile(int id, string name)
10721072
{
1073-
if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageExports))
1074-
return AccessDeniedView();
1075-
1076-
var profile = _exportService.GetExportProfileById(id);
1077-
if (profile == null)
1078-
return RedirectToAction("List");
1073+
if (_services.Permissions.Authorize(StandardPermissionProvider.ManageExports))
1074+
{
1075+
var profile = _exportService.GetExportProfileById(id);
1076+
if (profile != null)
1077+
{
1078+
var path = Path.Combine(profile.GetExportFolder(true), name);
10791079

1080-
var path = Path.Combine(profile.GetExportFolder(true), name);
1080+
if (!System.IO.File.Exists(path))
1081+
path = Path.Combine(profile.GetExportFolder(false), name);
10811082

1082-
if (!System.IO.File.Exists(path))
1083-
path = Path.Combine(profile.GetExportFolder(false), name);
1083+
if (System.IO.File.Exists(path))
1084+
{
1085+
var stream = new FileStream(path, FileMode.Open);
10841086

1085-
var stream = new FileStream(path, FileMode.Open);
1087+
var result = new FileStreamResult(stream, MimeTypes.MapNameToMimeType(path));
1088+
result.FileDownloadName = Path.GetFileName(path);
10861089

1087-
var result = new FileStreamResult(stream, MimeTypes.MapNameToMimeType(path));
1088-
result.FileDownloadName = Path.GetFileName(path);
1090+
return result;
1091+
}
1092+
}
1093+
}
10891094

1090-
return result;
1095+
return new EmptyResult(); // TODO
10911096
}
10921097

10931098
public ActionResult ResolveFileNamePatternExample(int id, string pattern)

src/Presentation/SmartStore.Web/Administration/Views/Export/InfoDeployment.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{
99
<div>
1010
@Html.IconForFileExtension(Path.GetExtension(fileName), false)
11-
<a href="@Url.Action("DownloadExportFile", new { id = Model.Id, name = fileName })" download>@fileName</a>
11+
<a href="@Url.Action("DownloadExportFile", new { id = Model.ProfileId, name = fileName })" download>@fileName</a>
1212
</div>
1313
}
1414
<div>

src/Presentation/SmartStore.Web/Administration/Views/Export/_Tab.Deployment.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<div class="clear"></div>
2727
<div class="btn-below">
28-
<a id="FileNamePatternDescriptionLink" href="javascript:void(0)">@T("Admin.Common.Show")...</a>
28+
<a id="FileNamePatternDescriptionLink" href="javascript:void(0)">@T("Admin.Common.Show")&hellip;</a>
2929
<div id="FileNamePatternDescription" class="btn-below hide">
3030
@FileNamePatternDescription()
3131
</div>

0 commit comments

Comments
 (0)